By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,827 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,827 IT Pros & Developers. It's quick & easy.

PHP MySQL Ranking System

Expert 100+
P: 1,168
Hey guys,
Here is my situation: I want to make a ranking system, which will rank users on their points. However the catch is, it should only be updated every 10 or 20 minutes so that ther is no confusion while users are comparing ranks. In the user table I have included a points field as well as a rank field. The points field can get updated over 10 or 20mins easily, that works, however I have no idea how to update ranks in a query. Can anyone shed some light on this?

Expand|Select|Wrap|Line Numbers
  1. UPDATE table SET rank=(SELECT rank ORDER BY points WHERE user='username')...
Or something?
Jan 30 '09 #1
Share this Question
Share on Google+
3 Replies

Expert 5K+
P: 5,058

Your best bet would probably be to create a stored procedure.
Try having it define a cursor to query the user table for the ID of the users, ordered by the score, and update each user's rank based on the position in the query.
Jan 30 '09 #2

Expert 100+
P: 1,584
how are ranks updated? (English version) don't attempt the code. If you explain it to me maybe I can give you a code example.

When you update a rank, how is it accumulated? is it a multiple of the points? i.e. 100 = 1st rank, 200 = 2nd rank, etc. ?

Feb 1 '09 #3

Expert 100+
P: 1,168
Figured out another method. Now I will just update the points every 10 minutes and use a normal ORDER BY MySQL qeury. Before I wanted to have a rank field which was calculated every 10minutes but instead I will calculate ranks on the fly and periodically count the points. Thanks for your help guys.
Feb 1 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.