Jump to content

[SOLVED] Rating System. Need help with ARRAYs or other Solution


codexx

Recommended Posts

Hello Everyone,

Just working on a script that lets users rate each other (1 - 10) . I'm not sure if this is the most effective way, but I was thinking of making each vote a new entry, then retrieve them all into an array. After that add all of the array and devide by the total results to get the average.

If this is the best solution I know how to add and get the average, just don't know how to implent the results into the array.

If this isn't the best solution could you please point me in the appropriate direction :).

Thanks Alot,
Sean
If you're planning on using a SQL database to store the results you can use the built in aggregator functions (SUM(), AVG(), etc) http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html to expedite your implementation.

Best,

Patrick
Thanks for you're quick reply Patrick!

Just another quick question so I'm sure I have this correctly.

How would this information then be outputted as normally I just use a while and fetch_assoc.

So far i've gotten..

$userrating = mysql_query("SELECT AVG(rating) FROM userratings WHERE rated = '".$user."'");

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.