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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.