Jump to content

Ranking System


marcus

Recommended Posts

Supposing you have a table "item" containing items to be rated

item
--------
item_id
item_name

Createa second table to store your users rating scores

rating
-----------
id
item_id          // id of the item being rated
score
user_id          // optional - use if users must login and can only vote once

To get the top 10 rankings

SELECT i.item_name, AVG(r.score) as avscore
FROM item i
INNER JOIN rating r ON i.item_id = r.item_id
ORDER BY avscore DESC
LIMIT 10
Link to comment
https://forums.phpfreaks.com/topic/24158-ranking-system/#findComment-110308
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.