viion Posted August 1, 2009 Share Posted August 1, 2009 this is my code: function topPoints() { // Pull Array of characters from database. $top_members_b = mysql_query("SELECT ". CHARACTER_CONFIG_PLAYNAME .", ". CHARACTER_CONFIG_POINTS ." FROM ". CHARACTER_DATABASE ." ORDER BY ". CHARACTER_CONFIG_POINTS ." DESC LIMIT 0,10"); if (!$top_members_b) { echo("<div id='error'><img src='img/icons/icon_cross.png'>Characters could not be loaded from database: " . mysql_error() . "</div>"); } // Print Results while ($toplist_b = mysql_fetch_array($top_members_b)) { $top_char_b = $toplist_b[CHARACTER_CONFIG_PLAYNAME]; $top_total_b = $toplist_b[CHARACTER_CONFIG_POINTS]; echo "<strong>$top_total_b</strong> : <a href='?mode=profile&user=$top_char'>$top_char_b</a><br/>"; } } It's result is: 9 9 9 6 6 6 5 3 3 18 Why is it not putting things above 10 to the highest? Quote Link to comment https://forums.phpfreaks.com/topic/168428-solved-order-by-a-number-descnot-workign-correctly/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 1, 2009 Share Posted August 1, 2009 Because you need to use an INT data type to store integers. You probably have a VARCHAR data type now and strings are sorted like you just posted, character by character, left to right. Quote Link to comment https://forums.phpfreaks.com/topic/168428-solved-order-by-a-number-descnot-workign-correctly/#findComment-888448 Share on other sites More sharing options...
viion Posted August 1, 2009 Author Share Posted August 1, 2009 okay thank you, i fixed it, some things in phpadmin had to change Quote Link to comment https://forums.phpfreaks.com/topic/168428-solved-order-by-a-number-descnot-workign-correctly/#findComment-888452 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.