Page 1 of 1

Very simple ratings script.

Posted: Tue Jun 04, 2002 9:49 pm
by mykg4orce
Ok i want to make a simple rating script. basically i will have the user choose a value between 10 and 0 from like a radio button or drop down menu, and that info will be fed into a MySQL Column, ok so then once i have lets say a few of these ratings done by differnt users how do calculate an overall average?

|------------------|
|ID|Message|Rating|
|------------------|
|1|hello|2|
|2|hi|9|
|3|yo man|7|
|4|homes|10|
|------------------|

ok so lets my table looks like that....how do i use the numbers from the "Ratings" column to display an overall average?

thank you!

Posted: Tue Jun 04, 2002 10:41 pm
by volka
I'd try the AVG(expr) function on rating ;)

Posted: Wed Jun 05, 2002 4:29 pm
by mykg4orce
thanks mate! :)

Posted: Wed Jun 05, 2002 7:38 pm
by lc
I think what I'd do is keep 2 numbers in a database.
1 the total of all votes added up
2 the total nr of votes

Oh and I do believe I remember that php doesn't work with 9.5 and such so I might use 10 in stead of 1 in the script just to make it work more detailed.

That should be easy enough to make a script do.

Then just divide one by the other. And put a dot in at the right place.