1 Reply Latest reply on Feb 16, 2012 9:39 PM by Burak Ueda

    Updating scores table and updating rank with php.

    Tony404 Level 1




      I have a scores table on my site that is 


      Scores : id - userid - rank - points -


      While using the site  users get points for doing stuff. The points are updated, but I don`t know how

      to update the rank of that user by comparing every one elses points and updating the rank numbers

      based on the users with most points in php.


      Hope you can help. Thanks

        • 1. Re: Updating scores table and updating rank with php.
          Burak Ueda Level 3

          Pull all the users from database sorted by points /// SELECT * FROM scores ORDER BY points DESC

          Create a loop within database records. /// Using while or foreach

          Create a counter outside the loop /// $count = 0

          Increase the count ($count++) inside the loop /// this will be your new ranking

          Update scores table with new ranking /// UPDATE scores SET rank = '{$count}' WHERE id = '{$db_resultsl["id"]}'


          Hope this helps...