Jump to content

[SOLVED] ordering table in MySQL with PHP


SergeantFlash

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.