Hung Kuen Kung Fu wrote:
> I get the follwing error on the page: PHP Parse error:
Your parse error is almost certainly caused by this line:
> $query = "SELECT SUM($row_rscomments['helpful']) FROM
$rscomments";
You can't use quotes around an associative array key in a
double quoted
string. Your line should be either this:
$query = "SELECT SUM($row_rscomments[helpful]) FROM
$rscomments";
or this enclosing the associative array in curly braces):
$query = "SELECT SUM({$row_rscomments['helpful']}) FROM
$rscomments";
However, you're actually making too much work for yourself
(and PHP).
The answer is to use the MySQL AVG() function:
SELECT AVG(thisColumn) AS thisColumn
FROM thisTable
--
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/