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`? Quote Link to comment 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"; Quote Link to comment 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']} "; } Quote Link to comment 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... Quote Link to comment 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'].""; } ?> 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.