PHP MySQL Ranking System

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    PHP MySQL Ranking System

    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?

    Code:
    UPDATE table SET rank=(SELECT rank ORDER BY points WHERE user='username')...
    Or something?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    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.

    Comment

    • dlite922
      Recognized Expert Top Contributor
      • Dec 2007
      • 1586

      #3
      Originally posted by TheServant
      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?

      Code:
      UPDATE table SET rank=(SELECT rank ORDER BY points WHERE user='username')...
      Or something?
      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. ?






      Dan

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        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.

        Comment

        Working...