Average numbers in PHP & MySQL
Posted: Sun Jul 05, 2009 11:05 am
Hi everyone,
I know how to work out an average number but was wondering if anyone could suggest a way in which this can be done in a rating sense.
I don't think it's necessary to store each vote in a table, presumably it would be best to grab the current value, add the new vote and divide by total number of votes (+1) then enter the result as the new value?
So two stored values are needed, total votes and current average?
Just asking if there is anything more to consider really and if anyone can represent this sum in php
I know how to work out an average number but was wondering if anyone could suggest a way in which this can be done in a rating sense.
I don't think it's necessary to store each vote in a table, presumably it would be best to grab the current value, add the new vote and divide by total number of votes (+1) then enter the result as the new value?
So two stored values are needed, total votes and current average?
Just asking if there is anything more to consider really and if anyone can represent this sum in php