PHP-Code schneller coden...

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • PHP-Code schneller coden...

    Hallo,
    kann mir sowas jemand in eine schleife coden ?
    danke..

    PHP-Code:
    $suche mysql_db_query("SELECT alg, information, kostenloses, geldverdienen, freizeit, musik, shopping, private, kommerzielle, webservice, toplisten, erotik, warez FROM p_kate_out WHERE ID=$id");
    $suche mysql_fetch_array($suche);

    $resultarray = array();
    $out mysql_db_query("SELECT alg, information, kostenloses, geldverdienen, freizeit, musik, shopping, private, kommerzielle, webservice, toplisten, erotik, warez FROM p_kate_in");
    while(
    $finde mysql_fetch_array($out)){
                     
    $check 0;
                     
    $credits mysql_db_query("SELECT id, url FROM p_user WHERE credits>=1 AND status=0 AND id!=$id");
                     
    $credits mysql_fetch_array($credits);

                     if(
    $suche[alg] == "1")
                                            {
                                      if(
    $suche[alg] == $finde[alg])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[information] == "1" && $check == "0")
                                            {if(
    $suche[information] == $finde[information])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[kostenloses] == "1" && $check == "0")
                                            {if(
    $suche[kostenloses] == $finde[kostenloses])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[geldverdienen] == "1" && $check == "0")
                                            {if(
    $suche[geldverdienen] == $finde[geldverdienen])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[freizeit] == "1" && $check == "0")
                                            {if(
    $suche[freizeit] == $finde[freizeit])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[musik] == "1" && $check == "0")
                                            {if(
    $suche[musik] == $finde[musik])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[shopping] == "1" && $check == "0")
                                            {if(
    $suche[shopping] == $finde[shopping])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[private] == "1" && $check == "0")
                                            {if(
    $suche[private] == $finde[private])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[kommerzielle] == "1" && $check == "0")
                                            {if(
    $suche[kommerzielle] == $finde[kommerzielle])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[webservice] == "1" && $check == "0")
                                            {if(
    $suche[webservice] == $finde[webservice])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[toplisten] == "1" && $check == "0")
                                            {if(
    $suche[toplisten] == $finde[toplisten])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[erotik] == "1" && $check == "0")
                                            {if(
    $suche[erotik] == $finde[erotik])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }

                                     if(
    $suche[warez] == "1" && $check == "0")
                                            {if(
    $suche[warez] == $finde[warez])
                                                    {
    array_push($resultarray$finde[id]);
                                                     
    $check 1;
                                                    }
                                            }
                                            if(
    $check == "1"){
                                            break;
                                            }
                                            } 

    also vor allem diese schleife...

    denn man kann das doch auch so irgendwie machen:
    PHP-Code:

    while($zeile=mysql_fetch_row($result)){
            for (
    $i 0$i <= 12$i++){
            if(
    $p_kate_in[$i]==$p_kate_in[$i]){
            
    $outurl="$zeile[1]";
            } 
    also in der art...

  • #2
    Nimm eine foreach Schleife oder ne switch() Abfrage

    Kommentar


    • #3
      genau das ist mein problem.. ich checke nicht ganu wie das mit foreach while oder switch geht :-(
      danke..

      Kommentar


      • #4
        So in etwa:

        PHP-Code:

        if($check == "0")
        {
            foreach(
        $suche as $key => $value)
            {
                if (
        $suche[$key] == $finde[$key])
                {
                    
        array_push($resultarray,$finde[id]);
                    
        $check 1;
                }
            }

        Kommentar

        Lädt...
        X