zampu Posted June 25, 2007 Share Posted June 25, 2007 Hello, ive made a script to order the players in my game by money, and its not working. Please help <?php session_start(); include_once "includes/db_connect.php"; include_once "includes/functions.php"; logincheck(); print "<tr valign='top'><td width=25%>"; print "</td>"; print "<td width=100%>"; //main table $getscores="SELECT money,username from users ORDER BY money ASC limit 25"; $getscores2=mysql_query($getscores) or die("Could not get scores"); $rank=1; print "<center><h3>Top 25 players</h3></center><center>"; print "<table width=90% class='maintable'><tr><td>Rank</td><td>Name</td><td>NetWorth</td></tr>"; while($getscores3=mysql_fetch_array($getscores2)) { $getscores3[username]=strip_tags($getscores3[username]); print "<tr><td>$rank</td><td>$getscores3[username]</td><td>$$getscores3[money]</td></tr>"; $rank++; } print "</table></center><br><br>"; ?> Its getting all of the info, and making the table, and listing it. Its just not ordering it by "money" Link to comment https://forums.phpfreaks.com/topic/57015-solved-order-by-problem-s/ Share on other sites More sharing options...
btherl Posted June 25, 2007 Share Posted June 25, 2007 What data type is money? Try this: ORDER BY CAST(money AS UNSIGNED) Link to comment https://forums.phpfreaks.com/topic/57015-solved-order-by-problem-s/#findComment-281665 Share on other sites More sharing options...
zampu Posted June 25, 2007 Author Share Posted June 25, 2007 Yes! it worked but it orders them backwards lol, how would i do this for DESC? Link to comment https://forums.phpfreaks.com/topic/57015-solved-order-by-problem-s/#findComment-281667 Share on other sites More sharing options...
btherl Posted June 25, 2007 Share Posted June 25, 2007 ORDER BY CAST(money AS UNSIGNED) DESC Link to comment https://forums.phpfreaks.com/topic/57015-solved-order-by-problem-s/#findComment-281672 Share on other sites More sharing options...
zampu Posted June 25, 2007 Author Share Posted June 25, 2007 *ambarased face* Thanks, i really appreciate it! Link to comment https://forums.phpfreaks.com/topic/57015-solved-order-by-problem-s/#findComment-281678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.