PDA

View Full Version : Rating System



Christopher
May 31st, 2002, 20:40
Ok, I have a mySQL database with jokes and stuff. I have (want) a rating system with two options - "Good" and "Bad."

I want to display something like "The Best 10," how would I kinda average those out (the good and the bad votes) to display them from the best to the worst?

spec
May 31st, 2002, 21:27
Its best to rate from 5
this gives alot more options and makes it easier to script.

make a numbers column then when an item is enter do a
$average_vote = $old_vote + $new_vote;
$average_vote = $average_vote / 2 ;

that will give you an average.
then do
"select * from jokes order by average_vote desc limit 5";

that will give you the top 5

Christopher
May 31st, 2002, 21:51
Ok, thanx.... Have to redo my tables now... lol :D