However the problem for gathering up the total counts of ratings submitted from each discussion, it will display only zero as the number, and doesn't seem to recognize computing the average of all the ratings.
The $outcome I thought should act like any mysql result. And the $access variable was intended to access within the array.
Am I missing something or misarranged something?
Code: Select all
<?php
@$outcome=mysql_query("SELECT rating FROM discussions WHERE articleID='$articleID'");
require("admin/failure.php");
while($access=mysql_fetch_array($outcome))
{
if (!$outcome) {
print "Error: no results returned (rating)";
}
$rate_count = mysql_num_rows($outcome);
if ($rate_count) {
for ($i=0; $i<$rate_count; $i++) {
$rating = mysql_fetch_array($outcome);
$total += $rating[rating];
}
$average = $total / $rate_count;
}
$average=$access["average"];
echo '<p><font face="Arial, Helvetica, sans-serif" size="2">',number_format($average,1,'.',''),'</font></p>';
}
?>