jack bro Posted April 7, 2009 Share Posted April 7, 2009 I have a leaderboard which i want to sort highest to lowest by rankpoints top 10 players I have this code. $c=mysql_query("SELECT * FROM users ORDER BY rankpoints DESC LIMIT 10"); while($d=mysql_fetch_object($c)){ echo "<tr><td><a href='profile.php?viewuser=$d->username'>$d->username</a></td><td>$d->totalref</td><td>$d->rank</td></tr>"; Don't sort into order for some reason. Jack. Quote Link to comment https://forums.phpfreaks.com/topic/153049-solved-why-wont-this-work-sort-into-descending/ Share on other sites More sharing options...
CloudSex13 Posted April 7, 2009 Share Posted April 7, 2009 Try: $c=mysql_query("SELECT * FROM users ORDER BY rankpoints LIMIT 10 DESC"); while($d=mysql_fetch_object($c)){ echo "<tr><td><a href='profile.php?viewuser=$d->username'>$d->username</a></td><td>$d->totalref</td><td>$d->rank</td></tr>"; Quote Link to comment https://forums.phpfreaks.com/topic/153049-solved-why-wont-this-work-sort-into-descending/#findComment-803830 Share on other sites More sharing options...
Maq Posted April 7, 2009 Share Posted April 7, 2009 What datatype is the rankpoints field? Quote Link to comment https://forums.phpfreaks.com/topic/153049-solved-why-wont-this-work-sort-into-descending/#findComment-803832 Share on other sites More sharing options...
premiso Posted April 7, 2009 Share Posted April 7, 2009 What is the field type of "rankpoints", it should be a numeric type (int etc) if it is not and it is a varchar or char, that is why. Quote Link to comment https://forums.phpfreaks.com/topic/153049-solved-why-wont-this-work-sort-into-descending/#findComment-803833 Share on other sites More sharing options...
PFMaBiSmAd Posted April 7, 2009 Share Posted April 7, 2009 And show what you are actually getting. Quote Link to comment https://forums.phpfreaks.com/topic/153049-solved-why-wont-this-work-sort-into-descending/#findComment-803835 Share on other sites More sharing options...
jack bro Posted April 7, 2009 Author Share Posted April 7, 2009 Was VARCHAR(100) now is INT(11) and still not working. http://www.midcity-mafia.com/leaderboard.php Jack. Quote Link to comment https://forums.phpfreaks.com/topic/153049-solved-why-wont-this-work-sort-into-descending/#findComment-803847 Share on other sites More sharing options...
Maq Posted April 7, 2009 Share Posted April 7, 2009 What you're referring to is not what you're trying to ORDER BY. You're outputting $d->totalref but you're ordering by rankpoints, which is it? Quote Link to comment https://forums.phpfreaks.com/topic/153049-solved-why-wont-this-work-sort-into-descending/#findComment-803858 Share on other sites More sharing options...
jack bro Posted April 7, 2009 Author Share Posted April 7, 2009 Wow, I'm such a goon, thanks Maq and everyone else, sorry for wasting your time. Jack. Quote Link to comment https://forums.phpfreaks.com/topic/153049-solved-why-wont-this-work-sort-into-descending/#findComment-803864 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.