Hey guys...im trying to do a rating script on my site where people can rate an image between 1- 10
the php code I have writeen is as follows:
// rating code
if($rate_image == "true")
{
$get_count = "SELECT rating, num_votes FROM ratings WHERE username='$username' and photo_id='{ID}'";
$db->query($get_count);
while(list($rating, $num_votes) = mysql_fetch_array($get_count))
{
$new_count = $num_votes+1;
$rating2 = $rating * $num_votes;
$new_rating = ($rating + $rating2) / $new_count;
$new_rating2 = number_format($new_rating, 2, '.', '');
$update_rating_query = "UPDATE ratings SET rating='$new_rating2', num_votes='$new_count' WHERE username='$username'";
$db->query($update_rating_query);
}
}
// end rating code
the html I am using is as follows:
<!-- BEGIN ratings -->
<form name="rating" method="post" action="userpage.php&rate_image=true">
<input type="hidden" name="photo_id" value="{ID}">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a title="Rate Image 1" href="userpage.php?username={USERNAME}&rate_image=1"><img src="images/r_1.gif" alt="Rate Image 1" height="18" width="12" border="0"></a></td>
<td width="17"></td>
<td><a title="Rate Image 2" href="userpage.php?username={USERNAME}&rate_image=2"><img src="images/r_2.gif" alt="Rate Image 2" height="18" width="13" border="0"></a></td>
<td width="17"></td>
<td><a title="Rate Image 3" href="userpage.php?username={USERNAME}&rate_image=3"><img src="images/r_3.gif" alt="Rate Image 3" height="18" width="13" border="0"></a></td>
<td width="17"></td>
<td><a title="Rate Image 4" href="userpage.php?username={USERNAME}&rate_image=4"><img src="images/r_4.gif" alt="Rate Image 4" height="18" width="13" border="0"></a></td>
<td width="17"></td>
<td><a title="Rate Image 5" href="userpage.php?username={USERNAME}&rate_image=5"><img src="images/r_5.gif" alt="Rate Image 5" height="18" width="13" border="0"></a></td>
<td width="17"></td>
<td><a title="Rate Image 6" href="userpage.php?username={USERNAME}&rate_image=6"><img src="images/r_6.gif" alt="Rate Image 6" height="18" width="13" border="0"></a></td>
<td width="17"></td>
<td><a title="Rate Image 7" href="userpage.php?username={USERNAME}&rate_image=7"><img src="images/r_7.gif" alt="Rate Image 7" height="18" width="13" border="0"></a></td>
<td width="17"></td>
<td><a title="Rate Image 8" href="userpage.php?username={USERNAME}&rate_image=8"><img src="images/r_8.gif" alt="Rate Image 8" height="18" width="13" border="0"></a></td>
<td width="17"></td>
<td><a title="Rate Image 9" href="userpage.php?username={USERNAME}&rate_image=9"><img src="images/r_9.gif" alt="Rate Image 9" height="18" width="13" border="0"></a></td>
<td width="17"></td>
<td><a title="Rate Image 10" href="userpage.php?username={USERNAME}&rate_image=10"><img src="images/r_10.gif" alt="Rate Image 10" height="18" width="27" border="0"></a></td>
</tr>
</table>
</form>
<!-- END ratings -->
obviously something is wrong cause nothing happens...any suggestions???
thanks
btw - does my code for the rating script look right?