rdkll
05-09-2008, 01:47 AM
Hello
I have a rating system. These are the values i store for each rating: Number of Votes, Previous Rating, Current Select Rating.
Which is the best way (formula) to calculate average rating??
Thanks for your help!
Dwagar
05-12-2008, 03:27 PM
Total Number Possible / Total Number users have voted times 100 gives a percentage if thats what your looking for.
Codebird
05-12-2008, 06:15 PM
yes that is the formula for all ratings I guess
arkin
05-12-2008, 07:53 PM
If its MySQL, MySQL does have an AVG() function for columns :]
shreder
05-13-2008, 11:57 AM
If it was me I would have created a special table for votes like that:
vote_id,item_voted,vote,date
And then do a select query for all the votes for a specific voted (the actual item voted).
Then when you have all the rows, calculate the average of all the "vote" field in all rows.
That way you can then manage your votes and delete/edit them if necessary.
Codebird
05-13-2008, 12:16 PM
If it was me I would have created a special table for votes like that:
vote_id,item_voted,vote,date
And then do a select query for all the votes for a specific voted (the actual item voted).
Then when you have all the rows, calculate the average of all the "vote" field in all rows.
That way you can then manage your votes and delete/edit them if necessary.
logically speaking that is the best way to be done!
aradapilot
05-14-2008, 06:00 AM
assuming number of votes includes the one stored as current select:
((previousrating * (numbervotes-1)) + selectedrating) / (numbervotes)
if the number of votes does not include the current, just switch it to:
((previousrating * numbervotes) + selectedrating) / (numbervotes+1)