Hi,
A few days ago I encountered a problem when coding a ranking system for my PHP game. What I need is a way to get a specific users rank simply by ordering the MySQL query by scores.
For example:
I may have a database with:
User - Score
krakken - 100
john - 200
markus - 400
malak - 50
And I want to find john's rank compared with the others. (Should be "2").
The only method I can think of at the moment is with a for loop. To query the database and order by "Score" then go through each "User" to see what rank they have which involves querying the database every time the loop goes through. I can predict now that with a lot of users this will dramatically slow doen the load time of the page.
If anyone has a solution I would be most greatful! Thanks!