In general, I do something like this:
<input type=radio name=vote value=1>One Star (or you could put an image here)
<input type=radio name=vote value=2>Two Stars
<input type=radio name=vote value=3>Three Stars
<input type=radio name=vote value=4>Four Stars
<input type=radio name=vote value=5>Five Stars
<input type=hidden name=id value="<? print "$id"; ?>">
That's the form. Now when the user chooses their vote and clicks submit, two values get passed to the next page. The "vote" and the ID. You need the ID so that you can keep track of which "thing" they were voting on.
Now you can record their vote in a database like this:
insert into votes (id,vote) values ($id,$vote)
Now when you are displaying some page and you want to show the average vote for that thing, you have to know the ID of the thing that you are showing. So you can say:
select vote from votes where id=$id
That will get you all the votes for that thing Then you can say:
$number = mysql_numrows($result);
That will tell you how many votes there were. Then you need to add up all the votes. You can do that like this:
$vote_total = 0;
while (list($vote) = @mysql_fetch_row($result)) { $vote_total += $vote; }
Then you divide the vote total by the number of votes like this:
if ($number > 0) {
$average = $vote_total / $number;
print "Average vote is: $average stars";
}
else { print "There aren't any votes yet"; }