I'm trying to use a for loop to convert a number into star images. My program reads from an SQL database to take a rating, which that works fine, but when I try to use a for loop it's a problem due to it being inside a table. Here's my code below:
<?
$conn = mysql_connect("mysql-g35a.mysqldbserver.com", "goodgu", "Goodguys123");
$select = mysql_select_db("goodgu");
$sql = 'SELECT * FROM `feedback` ORDER BY `Index` DESC LIMIT 0, 30 ';
$result = mysql_query($sql);
$num = mysql_numrows($result);
while($i < $num){
$name=mysql_result($result,$i,"name");
$make=mysql_result($result,$i,"make");
$model=mysql_result($result,$i,"model");
$year=mysql_result($result,$i,"year");
$comment=mysql_result($result,$i,"service");
$rating=mysql_result($result,$i,"rating");
$date=mysql_result($result,$i,"date");
print <<<HERE
<table width="570" border="0">
<tr>
<td width="208" bgcolor="#FF0000">$name</td>
<td width="352" bgcolor="#FFFFFF"> Rating: $rating Date of service: $date</td>
</tr>
<tr>
<td bgcolor="#FFFFCC">
$year $make $model</td>
<td valign="top" bgcolor="#FFFF99">$comment</td>
</tr>
</table>
HERE;
$i++;
}//end while
?>
Here's a snippet of what I'd like to be able to do:
print <<<HERE
<table width="570" border="0">
<tr>
<td width="208" bgcolor="#FF0000">$name</td>
<td width="352" bgcolor="#FFFFFF"> Rating:
for($i =0; $i<$rating; $i++){
<img src="images/star.jpg">
}
Date of service: $date</td>
</tr>
<tr>
<td bgcolor="#FFFFCC">
$year $make $model</td>
<td valign="top" bgcolor="#FFFF99">$comment</td>
</tr>
</table>
HERE;
But when I do that, it shows the for loop code in the table. I just want to be able to convert the rating into a number stars. How would I go about doing this?