Ok so I have a bit of code.
echo "<span class='sortstyle'><strong>Average rating:</strong> ";
while($row = mysql_fetch_array($result))
{
$rating1 += $row[rating1];
}
$avgrating = round($rating1/$numberofrows, 2);
echo $avgrating." / 5</span><span class='sortstyle'><strong>Total reviews:</strong> ".$numberofrows."</span>";
}
I want this to display the values from my database but from different rows so I tried.
echo "<span class='sortstyle'><strong>Average rating:</strong> ";
while($row = mysql_fetch_array($result))
{
$rating1 += $row[rating1];
}
$avgrating = round($rating1/$numberofrows, 2);
echo $avgrating." / 5</span><span class='sortstyle'><strong>Total reviews:</strong> ".$numberofrows."</span>";
}{
echo "<span class='sortstyle'><strong>Average rating:</strong> ";
while($row = mysql_fetch_array($result))
{
$rating += $row[rating];
}
$avgrating = round($rating/$numberofrows, 2);
echo $avgrating." / 5</span><span class='sortstyle'><strong>Total reviews:</strong> ".$numberofrows."</span>";
}
When I try it this way it displays a zero but if I change the second to a rating1 it displays correctly but it shows the same values as the first.
How can I get this to work right?
What I want it to do is each area displays the rating percentage based on the sql information.
Thank you.