Hi all,
I'm trying to display the average of each row displayed in my table but am having a bit of trouble, any assitance would be appreciated.
Basically the table displays the name, the score you gave them, and their average score. Here is my code below (example, names modified. Just the average of a single player done to test it shows the average) and any assistance would be appreciated.
<?php
$query = "SELECT ROUND(AVG(Rating),2) FROM userrating WHERE Playername LIKE 'player1' ";
$result = @mysql_query ($query);
$avg = mysql_fetch_array($result);
$userprofile= $_SESSION['name'];
$sql = mysql_query("SELECT * FROM userrating WHERE Ratedby = '$userprofile'");
echo "<table>
<tr>
<th> Name </th>
<th> My Rating </th>
<th> Average Rating </th>
</tr>";
while ($row = mysql_fetch_array($sql)){
echo "<td align=center>" . $row['Playername'] . "</td>";
echo "<td align=center>" . $row['Rating'] . "</td>";
echo "<td align=center>$avg[0]</td>";
echo "</tr>";
}
echo "</table>";
?>