Greaser9780 Posted February 15, 2007 Share Posted February 15, 2007 I am try to display data from my table in order of which clan has the most wins. Here is my code: $sql="SELECT `clan_name` FROM `bhdsingle` ORDER BY `wins`"; $res=mysql_query($sql) or die(mysqll_error()); while ($list = mysql_fetch_array($res)) { echo "{$list['clan_name']} <br>"; } It set up a list but puts least wins first. What else can I use? ORDER BY DESCENDING `wins`? Link to comment https://forums.phpfreaks.com/topic/38595-noobie/ Share on other sites More sharing options...
paul2463 Posted February 15, 2007 Share Posted February 15, 2007 $sql="SELECT `clan_name` FROM `bhdsingle` ORDER BY `wins` DESC"; Link to comment https://forums.phpfreaks.com/topic/38595-noobie/#findComment-185229 Share on other sites More sharing options...
Greaser9780 Posted February 15, 2007 Author Share Posted February 15, 2007 Figured it out by searching previous posts.TY though. Maybe you could help me with something else. Now I am trying to SELECT multiple things from the same query and list them the same way. I tried the following but got nowhere: $sql="SELECT (`clan_name`,`wins`,`losses`) FROM `bhdsingle` ORDER BY `wins` DESC"; $res=mysql_query($sql) or die(mysqll_error()); while ($list = mysql_fetch_array($res)) { echo "{$list['clan_name']}{$list['wins']}{$list['losses']} "; } Link to comment https://forums.phpfreaks.com/topic/38595-noobie/#findComment-185235 Share on other sites More sharing options...
worldworld Posted February 15, 2007 Share Posted February 15, 2007 Yes ORDER BY `wins` DESC is the key... Link to comment https://forums.phpfreaks.com/topic/38595-noobie/#findComment-185338 Share on other sites More sharing options...
paul2463 Posted February 15, 2007 Share Posted February 15, 2007 <?php $sql="SELECT `clan_name`,`wins`,`losses` FROM `bhdsingle` ORDER BY `wins` DESC"; $res=mysql_query($sql) or die(mysql_error()); //too many 'l' in mysql_error spelling while ($list = mysql_fetch_array($res)) { echo "".$list['clan_name']." - ".$list['wins']." - ".$list['losses'].""; } ?> Link to comment https://forums.phpfreaks.com/topic/38595-noobie/#findComment-185428 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.