Ankündigung

Einklappen
Keine Ankündigung bisher.

daten aus datenbank abrufen und id mit anderer tabelle umwandeln

Einklappen

Neue Werbung 2019

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

  • daten aus datenbank abrufen und id mit anderer tabelle umwandeln


    ich hoffe, das diese erklärung und die Grafik dazu verständlich ist. Würde es gerne auch mit PDO machen, aber da wahren bis jetzt alle versuche ein Fehlschlag. Hier ist mein Code zu diesem Problem:
    PHP-Code:
    <script type="text/javascript" src="http://wowdata.buffed.de/js/buffed-db-tooltips.js"></script>
    <?php
    $charID 
    $_GET['charID'];
    $conn mysql_connect("localhost""ich","123456") or die ("Verbindung nicht möglich");
    mysql_set_charset("utf8"$conn);
    mysql_select_db("web24_4"$conn) or die ("Datenbank existiert nicht");

    $output '';
    // Die SQL Befehle
    $strSQL "SELECT * FROM items WHERE ItemID IN(SELECT ItemID FROM char_items WHERE charID = $charID)";

    // Rüsstungsteile die vorhanden sind:
    // head, neck, shoulder, back, chest, shirt, tabard, wrist, hands, waist, legs, feet, finger1, finger2, trinket1, trinket2, mainHand, offHand

    // Query ausführen (die Datensatzgruppe $rs enthält das Ergebnis)
    if ( $rs mysql_query($strSQL) ) {

        
    // Schleifendurchlauf durch $rs
        // Jede Zeile wird zu einem Array ($row), mit mysql_fetch_array
        
    while($row mysql_fetch_array($rs)) {
           
    $output .= <<<EOF

        <table align="center" style="margin-left: auto; margin-right: auto; text-align: center;">
           <tr>
                <td colspan="3">
    {$row['name']}</td>
           </tr>
           <tr>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
                <td style="min-width: 250px; min-height: 250px;" rowspan="8"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
           </tr>
           <tr>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
           </tr>
           <tr>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
           </tr>
           <tr>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
           </tr>
           <tr>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
           </tr>
           <tr>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
           </tr>
           <tr>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
           </tr>
           <tr>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
                <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
           </tr>
           <tr>
                <td style="min-width: 25px;" colspan="3"><img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" />
                                                         <img src="http://eu.media.blizzard.com/wow/icons/18/
    {$row['icon']}.jpg" /></td>
           </tr>
        </table>

    EOF;
    }
    }

    $strSQLz "SELECT * FROM zusatz WHERE zusatz.charID=$charID";
        if ( 
    $rsz mysql_query($strSQLz) ) {
            while(
    $rowz mysql_fetch_array($rsz)) {

                
    $talText1 = ($rowz['talents0spec'])?'<font color="#00FF00"><b><u>'.$rowz['talents0name'].'</u></b></font>':$rowz['talents0name'];

                
    $output .= <<<EOF
                    <table align="center" border="1" bgcolor="{$Colors[$rowz['class']]}">
                        <tr>
                            <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
    {$rowz['talents0bild']}.jpg" width="25px" height="25px" />$talText1</td>
                            <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
    {$rowz['talents1bild']}.jpg" width="25px" height="25px" />{$rowz['talents1name']}</td>
                            <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
    {$rowz['professionspri0bild']}.jpg" width="25px" height="25px" />{$rowz['professionspri0lvl']}</td>
                            <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
    {$rowz['professionspri1bild']}.jpg" width="25px" height="25px" />{$rowz['professionspri1lvl']}</td>
                        </tr>
                        <tr>
                            <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
    {$rowz['professionssec0bild']}.jpg" width="25px" height="25px" />{$rowz['professionssec0lvl']}</td>
                            <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
    {$rowz['professionssec1bild']}.jpg" width="25px" height="25px" />{$rowz['professionssec1lvl']}</td>
                            <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
    {$rowz['professionssec2bild']}.jpg" width="25px" height="25px" />{$rowz['professionssec2lvl']}</td>
                            <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
    {$rowz['professionssec3bild']}.jpg" width="25px" height="25px" />{$rowz['professionssec3lvl']}</td>
                        </tr>
                        <tr><td colspan="4"><a href="test.php">ZUR&egrave;CK GILDENLISTE</a></td></tr>
                    </table>
    EOF;
    }
    }
    echo 
    $output;
    ?>


  • #2
    Weder die Problembeschreibung noch der Code machen sinn. Der erste Query sollte das machen was du willst, sowas formuliert man aber eigentlich als JOIN. http://de.wikibooks.org/wiki/Einf%C3...eiten_mit_JOIN
    Das was du dann mit dem Resultset dieses Queries machst ist aber quatsch. Du gibst für jeden Datensatz x mal das selbe Icon aus, macht irgendwie keinen Sinn.

    Kommentar


    • #3
      hatte ich gemerkt. hab es nun so gelöst, ist zwar bestimmt etwas umständlich und auch nicht in pdo wie ich es gerne hätte, aber so geht es. erst mal auch nur mit den kopf und hände getestet in der frontend tabelle
      PHP-Code:
      <script type="text/javascript" src="http://wowdata.buffed.de/js/buffed-db-tooltips.js"></script>
      <?php
      $charID 
      $_GET['charID'];
      $conn mysql_connect("localhost""BENUTZER","PASSWORT") or die ("Verbindung nicht möglich");
      mysql_set_charset("utf8"$conn);
      mysql_select_db("web24_4"$conn) or die ("Datenbank existiert nicht");

      $output '';
      // Die SQL Befehle
      $strSQL "SELECT * FROM char_items WHERE charID = $charID";

      // Rüsstungsteile die vorhanden sind:
      // head, neck, shoulder, back, chest, shirt, tabard, wrist, hands, waist, legs, feet, finger1, finger2, trinket1, trinket2, mainHand, offHand

      // Query ausführen (die Datensatzgruppe $rs enthält das Ergebnis)
      if ( $rs mysql_query($strSQL) ) {

          
      // Schleifendurchlauf durch $rs
          // Jede Zeile wird zu einem Array ($row), mit mysql_fetch_array
          
      while($row mysql_fetch_array($rs)) {

             
      $ahead "SELECT * FROM items WHERE ItemID = $row[head]";
                  if ( 
      $ehead mysql_query($ahead)){
                      while(
      $head mysql_fetch_array($ehead)){
                      
      $kopf $head;
                      }
                  }

              
      $aneck "SELECT * FROM items WHERE ItemID = $row[neck]";
                  if ( 
      $eneck mysql_query($aneck)){
                      while(
      $neck mysql_fetch_array($eneck)){
                       
      $hals $neck;
                      }
                  }

              
      $ashoulder "SELECT * FROM items WHERE ItemID = $row[shoulder]";
                  if ( 
      $eshoulder mysql_query($ashoulder)){
                      while(
      $shoulder mysql_fetch_array($eshoulder)){
                       
      $schulter $shoulder;
                      }
                  }

              
      $aback "SELECT * FROM items WHERE ItemID = $row[back]";
                  if ( 
      $eback mysql_query($aback)){
                      while(
      $back mysql_fetch_array($eback)){
                       
      $rucken $back;
                      }
                  }

              
      $achest "SELECT * FROM items WHERE ItemID = $row[chest]";
                  if ( 
      $echest mysql_query($achest)){
                      while(
      $chest mysql_fetch_array($echest)){
                       
      $brust $chest;
                      }
                  }

              
      $ashirt "SELECT * FROM items WHERE ItemID = $row[shirt]";
                  if ( 
      $eshirt mysql_query($ashirt)){
                      while(
      $shirt mysql_fetch_array($eshirt)){
                       
      $hemd $shirt;
                      }
                  }

              
      $atabard "SELECT * FROM items WHERE ItemID = $row[tabard]";
                  if ( 
      $etabard mysql_query($atabard)){
                      while(
      $tabard mysql_fetch_array($etabard)){
                       
      $wappen $tabard;
                      }
                  }

               
      $awrist "SELECT * FROM items WHERE ItemID = $row[wrist]";
                  if ( 
      $ewrist mysql_query($awrist)){
                      while(
      $wrist mysql_fetch_array($ewrist)){
                       
      $hgelenk $wrist;
                      }
                  }

               
      $ahands "SELECT * FROM items WHERE ItemID = $row[hands]";
                  if ( 
      $ehands mysql_query($ahands)){
                      while(
      $hands mysql_fetch_array($ehands)){
                       
      $hande $hands;
                      }
                  }

                
      $awaist "SELECT * FROM items WHERE ItemID = $row[waist]";
                  if ( 
      $ewaist mysql_query($awaist)){
                      while(
      $waist mysql_fetch_array($ewaist)){
                       
      $taille $waist;
                      }
                  }

               
      $alegs "SELECT * FROM items WHERE ItemID = $row[legs]";
                  if ( 
      $elegs mysql_query($alegs)){
                      while(
      $legs mysql_fetch_array($elegs)){
                       
      $hose $legs;
                      }
                  }

               
      $afeet "SELECT * FROM items WHERE ItemID = $row[feet]";
                  if ( 
      $efeet mysql_query($afeet)){
                      while(
      $feet mysql_fetch_array($efeet)){
                       
      $fusse $feet;
                      }
                  }

               
      $afinger1 "SELECT * FROM items WHERE ItemID = $row[finger1]";
                  if ( 
      $efinger1 mysql_query($afinger1)){
                      while(
      $finger1 mysql_fetch_array($efinger1)){
                       
      $ring1 $finger1;
                      }
                  }

              
      $afinger2 "SELECT * FROM items WHERE ItemID = $row[finger2]";
                  if ( 
      $efinger2 mysql_query($afinger2)){
                      while(
      $finger2 mysql_fetch_array($efinger2)){
                       
      $ring2 $finger2;
                      }
                  }

              
      $atrinket1 "SELECT * FROM items WHERE ItemID = $row[trinket1]";
                  if ( 
      $etrinket1 mysql_query($atrinket1)){
                      while(
      $trinket1 mysql_fetch_array($etrinket1)){
                       
      $schmuck1 $trinket1;
                      }
                  }

              
      $atrinket2 "SELECT * FROM items WHERE ItemID = $row[trinket2]";
                  if ( 
      $etrinket2 mysql_query($atrinket2)){
                      while(
      $trinket2 mysql_fetch_array($etrinket2)){
                       
      $schmuck2 $trinket2;
                      }
                  }

              
      $amainHand "SELECT * FROM items WHERE ItemID = $row[mainHand]";
                  if ( 
      $emainHand mysql_query($amainHand)){
                      while(
      $mainHand mysql_fetch_array($emainHand)){
                       
      $waffe $mainHand;
                      }
                  }

              
      $aoffHand "SELECT * FROM items WHERE ItemID = $row[offHand]";
                  if ( 
      $eoffHand mysql_query($aoffHand)){
                      while(
      $offHand mysql_fetch_array($eoffHand)){
                       
      $schild $offHand;
                      }
                  }

                 
      $output .= <<<EOF

          <table align="center" style="margin-left: auto; margin-right: auto; text-align: center;">
             <tr>
                  <td colspan="3">
      {$item[0]}</td>
             </tr>
             <tr>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$kopf['icon']}.jpg" /></td>
                  <td style="min-width: 250px; min-height: 250px;" rowspan="8"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$hande}.jpg" /></td>
             </tr>
             <tr>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
             </tr>
             <tr>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
             </tr>
             <tr>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
             </tr>
             <tr>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
             </tr>
             <tr>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
             </tr>
             <tr>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
             </tr>
             <tr>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
                  <td style="min-width: 25px;"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
             </tr>
             <tr>
                  <td style="min-width: 25px;" colspan="3"><img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" />
                                                           <img src="http://eu.media.blizzard.com/wow/icons/18/
      {$row['icon']}.jpg" /></td>
             </tr>
          </table>

      EOF;
      }
      }


      $strSQLz "SELECT * FROM zusatz WHERE zusatz.charID=$charID";
          if ( 
      $rsz mysql_query($strSQLz) ) {
              while(
      $rowz mysql_fetch_array($rsz)) {

                  
      $talText1 = ($rowz['talents0spec'])?'<font color="#00FF00"><b><u>'.$rowz['talents0name'].'</u></b></font>':$rowz['talents0name'];

                  
      $output .= <<<EOF
                      <table align="center" border="1" bgcolor="{$Colors[$row['class']]}">
                          <tr>
                              <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
      {$rowz['talents0bild']}.jpg" width="25px" height="25px" />$talText1</td>
                              <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
      {$rowz['talents1bild']}.jpg" width="25px" height="25px" />{$rowz['talents1name']}</td>
                              <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
      {$rowz['professionspri0bild']}.jpg" width="25px" height="25px" />{$rowz['professionspri0lvl']}</td>
                              <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
      {$rowz['professionspri1bild']}.jpg" width="25px" height="25px" />{$rowz['professionspri1lvl']}</td>
                          </tr>
                          <tr>
                              <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
      {$rowz['professionssec0bild']}.jpg" width="25px" height="25px" />{$rowz['professionssec0lvl']}</td>
                              <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
      {$rowz['professionssec1bild']}.jpg" width="25px" height="25px" />{$rowz['professionssec1lvl']}</td>
                              <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
      {$rowz['professionssec2bild']}.jpg" width="25px" height="25px" />{$rowz['professionssec2lvl']}</td>
                              <td style="min-width: 30px;"><img id="thumb" src="http://eu.media.blizzard.com/wow/icons/18/
      {$rowz['professionssec3bild']}.jpg" width="25px" height="25px" />{$rowz['professionssec3lvl']}</td>
                          </tr>
                          <tr><td colspan="4"><a href="test.php">ZUR&egrave;CK GILDENLISTE</a></td></tr>
                      </table>
      EOF;
      }
      }
      echo 
      $output;
      ?>

      Kommentar

      Lädt...
      X