serio Posted October 10, 2009 Share Posted October 10, 2009 Let's say I wanted the user to be able to choose ASC or DESC Could i do this with this code? <? $sort = $_REQUEST['sort']; // Gets the id of the shop from the URL. Ex: http://localhost/lols.php?id=1337 $shop would be equal to 1337 $sql = "SELECT * FROM avatars ORDER BY rdate"; $query = mysql_query($sql); echo error_reporting(E_ALL); $i = 0; if($sort) == "ASC" { $sql .= " ASC LIMIT 0, 10"; } else { $sql .= " DESC LIMIT 0, 10"; } } while($results = mysql_fetch_array($query)) { if($i == 0) { echo ""; } $desc = $results['desc']; $id = $results['id']; $category = $results['category']; $cost = $results['cost']; $name = $results['name']; $image = $results['image']; $release = $results['rdate']; echo "<div class='abox2'><div class='aheader2'>$name</div><div class='acontent2'><table border='0' cellpadding='5' cellspacing='1'><tr><td><a href=javascript:openpopup('avatars/avatars.php?id=$id')><img src='$image' border='0'></a></td><td valign='top'><a href=javascript:openpopup('avatars/avatars.php?id=$id')>$name - (click here for solution)</a></td></tr></table></div></div>"; $i++; if($i == 4) { echo ""; $i = 0; } } echo ""; ?> i've never done this before and I know the "=" or "==" on line 25 gives an error. but if i wanted it to be like index.php?page=avatars/index&=sort=ASC it would display ASC and if it was DESC it would display DESC Link to comment https://forums.phpfreaks.com/topic/177232-solved-ordering-by-desc-and-asc-help/ Share on other sites More sharing options...
fenway Posted October 17, 2009 Share Posted October 17, 2009 Solved how? Link to comment https://forums.phpfreaks.com/topic/177232-solved-ordering-by-desc-and-asc-help/#findComment-938819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.