I know its partially working because I get this:
13 people have voted, total amount in array adds up to 67 with overall rating of 5.2
you voted 7UPDATE image_bank SET numratings = 7 4 4 4 5 9 1 3 2 7 7 7 7 7, rating = 5.2 WHERE image_id = 5
But the base just doesn't update
Here is what i have so far (its for a rating system):
Code: Select all
$userrate = $_GET['rating'] ;
$currentimage = $_SESSION['currentimage'] ;
$query = "SELECT * FROM image_bank WHERE image_id = $currentimage" ;
$result = mysql_query($query) ;
while($row = mysql_fetch_array($result))
{
$currentrating = $row['rating'] ;
$numratings = $row['numratings'] ;
}
$breakdown = explode(" ",$numratings) ;
$count = count($breakdown) ;
$i = 0 ;
while($i < $count)
{
$range += $breakdown[$i] ;
$i++ ;
}
$currentrating = round($range / $count,1) ;
$newratecnt = $numratings . " " . $userrate ;
echo "$count people have voted, total amount in array adds up to $range
with overall rating of $currentrating" ;
echo "<br /> you voted $userrate" ;
if($userrate < 0)
{
echo "vote to small" ;
}
elseif($userrate > 10)
{
echo "vote to big" ;
}
else
{
$urate = "UPDATE image_bank SET numratings = $newratecnt, rating = $currentrating WHERE image_id = $currentimage" ;
mysql_query($urate) ;
echo "$urate" ;
}