I was trying to make a weighted avg. value for my 5 star rating script:
function raten($setvl)
{
global $book_id, $resulten, $dbhandle;
$resulten = mysql_query("SELECT SUM(rate)
FROM review
WHERE rate = '$setvl' AND
book_id = '$book_id",
$dbhandle);
$rowen = mysql_fetch_array($resulten);
return $rowen['SUM(rate)'];
}
Can anyone explain what I'm doing wrong?
SELECT SUM(rate) as tot_ratein the query and thenreturn $rowen['tot_rate'];if(!mysql_query(...)) /*error*/ else{ if(!mysql_fetch_array(...)) /*error*/ { /*handle result*/}and see what happens