Forum Moderators: coopster
I need a basic rating script to rate an image from 1-5 or 1-10 or whatever. I don't need the ability for people to post their own images, nor do i neccessarily need the ability for it to be restricted to members to vote. Just want the ability to rate something, and then have the results come up not only on the page of the image you rated, but also on another page with a top 10 rating list.
[edited by: coopster at 11:52 am (utc) on May 27, 2005]
[edit reason] no solicitations please [/edit]
If it's in db you can add two fields: total, votes (where total is total sum of all marks and votes is the number of votes)
Then
"SELECT total, votes FROM table WHERE img_id='$img_id'"
//read the db
$mean = $total/$votes;
$mean = number_format($mean, 2, '.', '');
to update the db call:
$mark = validate($_POST["mark"]);// validate, do the number doesn't exceed minimal and maximal value
then
"UPDATE table SET total=total + $mark, votes=votes + 1"
That should do it. For more direct code just ask. This above is just a start on how to do that. you need the form to post the mark, etc
Michal Cibor