Quote:
Originally Posted by Vince
In order to find the player's position you need to count the number of players that have a score that is higher than the current player's. Such a count query would look somewhat like this:
PHP код:
SELECT COUNT(*) + 1 AS position FROM playerdata WHERE score > ?
Now the question mark needs to be replaced with the player's score. If you don't know what that is then you need another query to find out.
PHP код:
SELECT score FROM playerdata WHERE id = %d
Then you need to combine both queries
PHP код:
SELECT COUNT(*) + 1 AS position FROM playerdata WHERE score > (SELECT score FROM playerdata WHERE id = %d)
Also put an index on the score column to speed up searches.
|
I'm very grateful for you replying, although I don't completely understand it, i would be very thankful if you added your count query to my code I posted above, like I mentioned before, I'm very basic when it comes to these things, and clearly seeing as you're an expert, it shouldn't take you long. You can skip the index part if you want, I can figure out how to do that myself, just want the general command working.