Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

Updating scores table and updating rank with php.

Guest
Feb 14, 2012 Feb 14, 2012

Hi

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

TOPICS
Server side applications
591
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 16, 2012 Feb 16, 2012
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines