Organizing these items by id?
Posted: Sun Jul 15, 2007 8:37 pm
I have the following code:
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:
but that did not work. So is there a way to make those items list via id?
Code: Select all
$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 "";
}
}
}Code: Select all
$res = mysql_query("SELECT id,name,description,url,store,price,preview FROM collection WHERE id=$fav");
$img = mysql_fetch_row($res);