Orionsbelter Posted March 30, 2009 Share Posted March 30, 2009 Ok, am wanting to out put my top 10 forum posters but its not working here is the code <?php $ex_query = mysql_query("SELECT * FROM `user_info` WHERE staff='0' ORDER BY `posts` DESC LIMIT 10"); while ($ex = mysql_fetch_array($ex_query)) { echo " <tr> <td height='20' bgcolor='#333333'><div align='center'><a href='profile.php?user=$ex[username]'>$ex[username]</a></div></td> </tr> "; }?> this out puts 10 people but not from highest to low or in an order help please! Quote Link to comment https://forums.phpfreaks.com/topic/151763-php-top-10-order-by-not-working/ Share on other sites More sharing options...
Maq Posted March 30, 2009 Share Posted March 30, 2009 Your code looks fine to me. Column "posts" is an integer right? Quote Link to comment https://forums.phpfreaks.com/topic/151763-php-top-10-order-by-not-working/#findComment-796893 Share on other sites More sharing options...
Orionsbelter Posted March 30, 2009 Author Share Posted March 30, 2009 what do you mean? Quote Link to comment https://forums.phpfreaks.com/topic/151763-php-top-10-order-by-not-working/#findComment-796901 Share on other sites More sharing options...
lonewolf217 Posted March 30, 2009 Share Posted March 30, 2009 what is the data type of your "posts" column in SQL Quote Link to comment https://forums.phpfreaks.com/topic/151763-php-top-10-order-by-not-working/#findComment-796903 Share on other sites More sharing options...
Maq Posted March 30, 2009 Share Posted March 30, 2009 what do you mean? I'm talking about in the MySQL table. If posts isn't an integer, if it's a VARCHAR, then it will order alphabetically. i.e: it will put 23 after 20001. Quote Link to comment https://forums.phpfreaks.com/topic/151763-php-top-10-order-by-not-working/#findComment-796916 Share on other sites More sharing options...
Orionsbelter Posted March 30, 2009 Author Share Posted March 30, 2009 varchar(100) Quote Link to comment https://forums.phpfreaks.com/topic/151763-php-top-10-order-by-not-working/#findComment-796917 Share on other sites More sharing options...
Orionsbelter Posted March 30, 2009 Author Share Posted March 30, 2009 LOL am a noob thanks Quote Link to comment https://forums.phpfreaks.com/topic/151763-php-top-10-order-by-not-working/#findComment-796921 Share on other sites More sharing options...
Maq Posted March 30, 2009 Share Posted March 30, 2009 LOL am a noob thanks We learn from our mistakes, at least if something like this happens again you'll know what most likely problem is (hopefully) If this solves your problem please mark as [sOLVED]. Quote Link to comment https://forums.phpfreaks.com/topic/151763-php-top-10-order-by-not-working/#findComment-796926 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.