SergeantFlash Posted August 11, 2008 Share Posted August 11, 2008 I have this code inside a php file: $query = "SELECT * FROM {$table} order by kills desc LIMIT 0,12"; This code orders the rows in the table from highest to lowest by kills. For example: Name | Kills --------------- Bob 300 Joe 230 Mike 50 Rob 50 However, some players would get the same amount of kills, how can I make it so, out of the players with the same kills, it orders them from newest to oldest (order them by emp_id, which is a variable I made that automatically increments by one, so the newest submission would have the higher number). So the table would look like this (since Rob was the newest person to play the game): Name | Kills --------------- Bob 300 Joe 230 Rob 50 Mike 50 Any help is appreciated. Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/119201-solved-ordering-table-in-mysql-with-php/ Share on other sites More sharing options...
Barand Posted August 11, 2008 Share Posted August 11, 2008 ORDER BY kills DESC, id DESC Link to comment https://forums.phpfreaks.com/topic/119201-solved-ordering-table-in-mysql-with-php/#findComment-614007 Share on other sites More sharing options...
SergeantFlash Posted August 11, 2008 Author Share Posted August 11, 2008 That works great! Thanks a lot Barand!! Link to comment https://forums.phpfreaks.com/topic/119201-solved-ordering-table-in-mysql-with-php/#findComment-614060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.