Monk3h Posted April 23, 2008 Share Posted April 23, 2008 Why isnt this brining back 10 people from the players database ordered most to least Chatlines. :S <?php $tsel = mysql_query("select * from players order by chatline desc limit 10"); while ($top = mysql_fetch_array($tsel)) { print "<tr><td>$top[user] ($top[id])</td><td>$top[chatline]</td></tr>"; } ?> It brings back the data needed.. It just dosnt order it by chatlines.. Link to comment https://forums.phpfreaks.com/topic/102618-order-by-des-not-working/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 23, 2008 Share Posted April 23, 2008 Chatline is probably strings and it is probably ordering them correctly (for the data type they are.) You would need to post an example of what your data is and what results you are getting and what you want it to be. Link to comment https://forums.phpfreaks.com/topic/102618-order-by-des-not-working/#findComment-525523 Share on other sites More sharing options...
Monk3h Posted April 23, 2008 Author Share Posted April 23, 2008 Everytime some one says somthing in chat it changes there chatlines by +1 I want to display the top 10 chatty people.. It should display it by Chatlines but instead its ordered like this. Lines in Chat Name (ID) Chat Lines Mooie (59) 21 SaRawr (89) 2 Monk3h (2) 18 andis0311 (22) 0 Dunk3r (1) 0 Link to comment https://forums.phpfreaks.com/topic/102618-order-by-des-not-working/#findComment-525525 Share on other sites More sharing options...
AndyB Posted April 23, 2008 Share Posted April 23, 2008 21,2,18,0,0 is sorted descending for STRING values. You need a NUMERIC type to sort numerically. That's what PFMaBiSmAd suggested. Link to comment https://forums.phpfreaks.com/topic/102618-order-by-des-not-working/#findComment-525529 Share on other sites More sharing options...
Monk3h Posted April 23, 2008 Author Share Posted April 23, 2008 How do i do that? Link to comment https://forums.phpfreaks.com/topic/102618-order-by-des-not-working/#findComment-525532 Share on other sites More sharing options...
AndyB Posted April 23, 2008 Share Posted April 23, 2008 How do i do that? database field definition Link to comment https://forums.phpfreaks.com/topic/102618-order-by-des-not-working/#findComment-525536 Share on other sites More sharing options...
sasa Posted April 24, 2008 Share Posted April 24, 2008 try ORDER BY chatline+0 Link to comment https://forums.phpfreaks.com/topic/102618-order-by-des-not-working/#findComment-525736 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.