Thread: Scoreboard
View Single Post
  #2  
Old 12-12-2014, 08:48 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by prozacboy666 View Post
Use SQL. Here is how I would do it.
When a new score comes in do a select on the database for the minimum score to get into the top20.
PHP Code:
SELECT MIN(scoreFROM myTable
If new score > min, insert new score into the database and delete the min score.
The only thing is you would have to do two queries to delete the min score from the database something like
PHP Code:
minId SELECT id FROM myTable WHERE score = (SELECT min(scoreFROM myTable)
DELETE FROM top20 WHERE id minId 
Then all you have to do is selects on that table if you are looking for the top20
PHP Code:
SELECT FROM top20 ORDER BY score DESC 
You probably could get the ID and delete it from the database all in one query but this should be fast enough.
You'd need three queries.
1,) Find the minimum score
2,) Add the score
3,) Delete old score


I guess it's what you want to store.
__________________
Reply With Quote