我试图加权平均值。我的5星评级脚本的价值:
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)'];
}
有谁能解释我做错了什么?
答案 0 :(得分:1)
您在查询中错过了'。变化...
"SELECT SUM(rate) FROM review WHERE rate = '$setvl' AND book_id = '$book_id"
为...
"SELECT SUM(rate) FROM review WHERE rate = '$setvl' AND book_id = '$book_id'"