Rating script problem - Wont update database

PythonPython Forum LeaderThe Royal RAM
I have this:

[PHP] $siteid = $_POST[siteid];
$newrating = $_POST[rating];

$result = mysql_query("SELECT `rating`, `numvotes` FROM `reviews_site` WHERE `id` = $siteid");
while($rate=mysql_fetch_array($result)){
$curnumvotes = $rate[numvotes];
$currating = $rate[rating];
}
$curnumvotes++;
$newnumvotes = $curnumvotes;

$final1 = ($currating + $newrating); // add old and new
$final2 = ($final1/$newnumvotes); // get average
$final2 = number_format($final2, 2, '.', '');
$query = "UPDATE `reviews_site` SET `rating` = $final && `numvotes` = $newnumvotes WHERE `id` = $siteid";
$uresult = mysql_query($query);[/PHP]

$_POST[siteid] is equal to 2
$_POST[rating] is equal to any number from 0-5, depends in what is submitted at form.

This basically is supposed to take the original rating value, add it to the new submitted rating value and then divide it by the number of votes.

Ive echoed it all out step by step to see if its doing the calculations and it does but it wont update the database with the new values.

Any suggestions?

The Royal Ram

Comments

Sign In or Register to comment.