Jump to content

[SOLVED] Organizing these items by id?


djfox

Recommended Posts

I have the following code:

 

$res = mysql_query("SELECT coll_inven,id FROM userdata WHERE login='$log'");
$rows = mysql_fetch_row($res);
mysql_free_result($res);
$favs = explode(',',$rows[0]);

//for each favorite get url and display
foreach($favs as $fav){
   if( $fav ){
      $res = mysql_query("SELECT id,name,description,url,store,price,preview FROM collection WHERE id=$fav");
      $img = mysql_fetch_row($res);
      
      
      if( $colCount%20 == 0 ){
echo "<tr>";
      }
      $colCount = $colCount + 1;
      echo "<td><a href=collectionview.php?id=$fav><img src='collection/$img[6]' border=0></a>";
      if(($_SESSION['level2']>6) || ( $_SESSION['level2']>1 && $_SESSION['sess_name'])){
         echo "";
      }
     
   }
}

 

The items are being displayed fine but how do I get them to be displayed in order of their id? I tried ORDER BY id ASC in this string:

      $res = mysql_query("SELECT id,name,description,url,store,price,preview FROM collection WHERE id=$fav");
      $img = mysql_fetch_row($res);

 

but that did not work. So is there a way to make those items list via id?

Link to comment
Share on other sites

Can we see the output of....

 

<?php

  $res = mysql_query("SELECT coll_inven,id FROM userdata WHERE login='$log'"); 
  $rows = mysql_fetch_row($res);
  mysql_free_result($res);
  $favs = explode(',',$rows[0]);

  foreach($favs as $fav){
     if( $fav ){
        $res = mysql_query("SELECT id,name,description,url,store,price,preview FROM collection WHERE id=$fav ORDER BY id ASC");
        $img = mysql_fetch_row($res);
        print_r($img);  
     }
  }

?>

 

?

Link to comment
Share on other sites

Yeah.. well that screenshot doesn't help at all. I ask again.... can we see the output of...

 

<?php

  $res = mysql_query("SELECT coll_inven,id FROM userdata WHERE login='$log'"); 
  $rows = mysql_fetch_row($res);
  mysql_free_result($res);
  $favs = explode(',',$rows[0]);

  foreach($favs as $fav){
     if( $fav ){
        $res = mysql_query("SELECT id,name,description,url,store,price,preview FROM collection WHERE id=$fav ORDER BY id ASC");
        $img = mysql_fetch_row($res);
        print_r($img);  
     }
  }

?>

Link to comment
Share on other sites

The only other way I can think to show you the output is this:

<table border=0>
<tr><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=10><img src='collection/goldshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=10><img src='collection/goldshell_pre.png' border=0></a><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=3><img src='collection/darkpurpleshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=1><img src='collection/darkblueshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=6><img src='collection/lightredshell_pre.png' border=0></a><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=2><img src='collection/lightblueshell_pre.png' border=0></a><td><a href=collectionview.php?id=11><img src='collection/silvershell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=11><img src='collection/silvershell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=11><img src='collection/silvershell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=4><img src='collection/lightpurpleshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=11><img src='collection/silvershell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=10><img src='collection/goldshell_pre.png' border=0></a><td><a href=collectionview.php?id=10><img src='collection/goldshell_pre.png' border=0></a><td><a href=collectionview.php?id=11><img src='collection/silvershell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=10><img src='collection/goldshell_pre.png' border=0></a><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><td><a href=collectionview.php?id=5><img src='collection/darkredshell_pre.png' border=0></a><td><a href=collectionview.php?id=10><img src='collection/goldshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=9><img src='collection/blackshell_pre.png' border=0></a><tr><td><a href=collectionview.php?id=7><img src='collection/darkgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a><td><a href=collectionview.php?id=8><img src='collection/lightgreenshell_pre.png' border=0></a></table>
</table>

 

Unless you mean something else.

Link to comment
Share on other sites

Unless you mean something else.

 

Yes. I meen show me the output of the code Ive posted! How hard is it?

 

<?php

  $res = mysql_query("SELECT coll_inven,id FROM userdata WHERE login='$log'"); 
  $rows = mysql_fetch_row($res);
  mysql_free_result($res);
  $favs = explode(',',$rows[0]);

  foreach($favs as $fav){
     if( $fav ){
        $res = mysql_query("SELECT id,name,description,url,store,price,preview FROM collection WHERE id=$fav ORDER BY id ASC");
        $img = mysql_fetch_row($res);
        echo '<pre>';
        print_r($img);
        echo '</pre>';  
     }
  }

?>

Link to comment
Share on other sites

There is no need to insult me or talk that way to me when you have volunteered to help me.

 

Apparently I didn`t get what you saying until just a moment ago. (I couldn`t even post the whole thing because the forum says it`s too big):

 

Array
(
    [0] => 1
    [1] => Dark Blue Shell
    [2] => A dark blue shell found at the sea floor of the reefs at the edge of Pacinity.
    [3] => darkblueshell.png
    [4] => 7
    [5] => 
    [6] => darkblueshell_pre.png
)

Link to comment
Share on other sites

The code I posted...

 

<?php

  $res = mysql_query("SELECT coll_inven,id FROM userdata WHERE login='$log'"); 
  $rows = mysql_fetch_row($res);
  mysql_free_result($res);
  $favs = explode(',',$rows[0]);

  foreach($favs as $fav){
     if( $fav ){
        $res = mysql_query("SELECT id,name,description,url,store,price,preview FROM collection WHERE id=$fav ORDER BY id ASC");
        $img = mysql_fetch_row($res);
        echo '<pre>';
        print_r($img);
        echo '</pre>';  
     }
  }

?>

 

only produces an opening and closing

<pre>

tag. As well as a nicely formatted output of your query result in the form of an array. Your code produces html tables and the like, I want (need) the output of my code.

Link to comment
Share on other sites

There is no need to insult me or talk that way to me when you have volunteered to help me.

 

Apparently I didn`t get what you saying until just a moment ago. (I couldn`t even post the whole thing because the forum says it`s too big):

 

Array
(
    [0] => 1
    [1] => Dark Blue Shell
    [2] => A dark blue shell found at the sea floor of the reefs at the edge of Pacinity.
    [3] => darkblueshell.png
    [4] => 7
    [5] => 
    [6] => darkblueshell_pre.png
)

 

I'm going to need a few more at least so I can see whats going on. Post the first 10 or so.

Link to comment
Share on other sites

Array
(
    [0] => 1
    [1] => Dark Blue Shell
    [2] => A dark blue shell found at the sea floor of the reefs at the edge of Pacinity.
    [3] => darkblueshell.png
    [4] => 7
    [5] => 
    [6] => darkblueshell_pre.png
)

Array
(
    [0] => 1
    [1] => Dark Blue Shell
    [2] => A dark blue shell found at the sea floor of the reefs at the edge of Pacinity.
    [3] => darkblueshell.png
    [4] => 7
    [5] => 
    [6] => darkblueshell_pre.png
)

Array
(
    [0] => 2
    [1] => Light Blue Shell
    [2] => A light blue shell found in the reefs near Pacinity.
    [3] => lightblueshell.png
    [4] => 7
    [5] => 
    [6] => lightblueshell_pre.png
)

Array
(
    [0] => 2
    [1] => Light Blue Shell
    [2] => A light blue shell found in the reefs near Pacinity.
    [3] => lightblueshell.png
    [4] => 7
    [5] => 
    [6] => lightblueshell_pre.png
)

Array
(
    [0] => 2
    [1] => Light Blue Shell
    [2] => A light blue shell found in the reefs near Pacinity.
    [3] => lightblueshell.png
    [4] => 7
    [5] => 
    [6] => lightblueshell_pre.png
)

Array
(
    [0] => 2
    [1] => Light Blue Shell
    [2] => A light blue shell found in the reefs near Pacinity.
    [3] => lightblueshell.png
    [4] => 7
    [5] => 
    [6] => lightblueshell_pre.png
)

Array
(
    [0] => 4
    [1] => Light Purple Shell
    [2] => A shell found on the sea floor in the reefs near Pacinity.
    [3] => lightpurpleshell.png
    [4] => 7
    [5] => 
    [6] => lightpurpleshell_pre.png
)

Array
(
    [0] => 1
    [1] => Dark Blue Shell
    [2] => A dark blue shell found at the sea floor of the reefs at the edge of Pacinity.
    [3] => darkblueshell.png
    [4] => 7
    [5] => 
    [6] => darkblueshell_pre.png
)

Array
(
    [0] => 2
    [1] => Light Blue Shell
    [2] => A light blue shell found in the reefs near Pacinity.
    [3] => lightblueshell.png
    [4] => 7
    [5] => 
    [6] => lightblueshell_pre.png
)

Array
(
    [0] => 2
    [1] => Light Blue Shell
    [2] => A light blue shell found in the reefs near Pacinity.
    [3] => lightblueshell.png
    [4] => 7
    [5] => 
    [6] => lightblueshell_pre.png
)

Link to comment
Share on other sites

Ok.... I think I see the issue. Its kinda hard to explain though. Shouldn't you expect more then one result from this query...?

 

$res = mysql_query("SELECT id,name,description,url,store,price,preview FROM collection WHERE id=$fav ORDER BY id ASC");

 

If so... you need to loop that result too. Try this and show me the output.

 

<?php

  if ($res = mysql_query("SELECT coll_inven FROM userdata WHERE login='$log'")) {
    if (mysql_num_rows($res)) { 
      $rows = mysql_fetch_assoc($res);
      if ($res = mysql_query("SELECT id,name,description,url,store,price,preview FROM collection WHERE id IN('{$rows['coll_inven']}') ORDER BY id ASC")) {
        if (mysql_num_rows($res)) {
          $i = 1;
          while ($row = mysql_fetch_assoc($res)) {
            echo "Record $i<br />";
            echo '<pre>';
            print_r($row['id']);
            echo '</pre>';
            $i++;  
         }
       }
    }
  }

?>

Link to comment
Share on other sites

Well yours runs an unlimitted number of queries within a loop. Mine is more efficient (more results less work) becuase it gets the job done in one query (well two technically).

 

This meens the server needs to do less work, your pages should load faster... more efficient.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.