Jump to content

Archived

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

marcus

Ranking System

Recommended Posts

what would be a good way to start out a ranking system?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

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.