djfox Posted July 16, 2007 Share Posted July 16, 2007 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? Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 $res = mysql_query("SELECT id,name,description,url,store,price,preview FROM collection WHERE id=$fav ORDER BY id ASC"); Should work fine. What field type is id? Quote Link to comment Share on other sites More sharing options...
rameshfaj Posted July 16, 2007 Share Posted July 16, 2007 Order by ASC is the default case. Try to use order by id DESC and see if that does the task. Quote Link to comment Share on other sites More sharing options...
djfox Posted July 16, 2007 Author Share Posted July 16, 2007 It`s still not ordering them. id is an auto increment int primary. Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 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); } } ?> ? Quote Link to comment Share on other sites More sharing options...
djfox Posted July 16, 2007 Author Share Posted July 16, 2007 I can`t give you a link to the page itself (because you have to be logged in and have entries to the field) but I do have a screenshot made: http://i174.photobucket.com/albums/w120/beloveddoll/screen.jpg Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 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); } } ?> Quote Link to comment Share on other sites More sharing options...
djfox Posted July 16, 2007 Author Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 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>'; } } ?> Quote Link to comment Share on other sites More sharing options...
djfox Posted July 16, 2007 Author Share Posted July 16, 2007 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 ) Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
djfox Posted July 16, 2007 Author Share Posted July 16, 2007 I just posted it in my post. Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
djfox Posted July 16, 2007 Author Share Posted July 16, 2007 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 ) Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 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++; } } } } ?> Quote Link to comment Share on other sites More sharing options...
djfox Posted July 16, 2007 Author Share Posted July 16, 2007 Someone contacted me off forum and gave me this little piece: sort($favs); I put that in and that did the trick. Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 That last piece of code I posted should do the same thing but alot more efficiently as it only uses 2 queries, yours used many queries within a loop. Quote Link to comment Share on other sites More sharing options...
djfox Posted July 16, 2007 Author Share Posted July 16, 2007 What do you mean by efficiently? Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.