I'm thinking this page would get accessed a fair bit, or could be, and the only way I know I think is too DB access intensive.
Thanks for any help
Yeah, that would work provided your score is based on a column in the database. Something like "SELECT name, score FROM users ORDER BY score DESC LIMIT 10" (basically what you have) will pull up the top scores. And then just use a cron set to run however often you want it to update.Baseball435 wrote:i forget how i did it but there is a way you can grab information from the sql server like "SELECT * FROM x ORDER BY id DESC 10". something like that. its what shoutboxes use
As far as you're not looping through thousands of users, you can run it as per query basis. So to speak, as long as your toplist ain't going to be looping through thousands, you can run it once everytime someone wants to check it!Jackolantern wrote:Yeah, that would work provided your score is based on a column in the database. Something like "SELECT name, score FROM users ORDER BY score DESC LIMIT 10" (basically what you have) will pull up the top scores. And then just use a cron set to run however often you want it to update.Baseball435 wrote:i forget how i did it but there is a way you can grab information from the sql server like "SELECT * FROM x ORDER BY id DESC 10". something like that. its what shoutboxes use
Although I think it would be better to run it more often than once a day, as that helps feed the competition for the top slots. A small script like this basically takes almost no resources to run, so running it once every 10 or 15 minutes will have almost no impact on resources versus running it once a day at midnight. This way, players can immediately see the fruits of their work, and the over-taken player can immediately start playing harder to try to take their slot back.
Yeah, for something that is not critical for it to only run once, such as a high scores page, the "page view" method would work fineCallan S. wrote:In the end I just made it record the last time the high score page was looked at, and if it's more than thirty minutes, it then updates the highscores. No cron needed.