I am creating a website in which users can log on and review Tablet PC's On tablet page visitors to the site can see the reviews left by other users. Despite users being able to review 5 tablets, the 'ipad' page for example will only show 'ipad' review. The code can be seen below:
<?php
include('connection.php');
$result = mysql_query("SELECT * FROM tt_review WHERE product = 'Apple iPad'");
echo "<table border='1'>
<tr>
</tr>";
while($row = mysql_fetch_array($result)) //This function is calling the results variable and displaying them within the rows below
{
echo "<tr>"; //this code tells the page to output the table rows that are defined above
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['date'] . "</td>"; //each row is then executed using the table data function
echo "<td>" . $row['product'] . "</td>";
echo "<td>" . $row['star'] . "</td>";
echo "<td>" . $row['comment'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
I have a field in my database called 'star' which is the rating the users have gave the tablet. 1, 2, 3, 4 or 5 are the options. I need code that works out the average of the 'star' rating from the 'ipad' page and to display an image based on whatever number it is.
All help is greatly appreciated as I am a newcomer and cant seem to find the answer online. Thanks Jonathan