I'm populating a HTML table after retrieving data from a mysql table. In this html table that will end up being about 10 or so rows long, I would like the first 3 rows to have a bronze, silver and gold background color.
This will be done by giving the first 3 rows that are printed from this loop a specific CSS class, while the remaining rows in the table will be given no class.
Here is the PHP at the moment:
PHP Code:
$result = mysql_query("SELECT * FROM table") or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
// Echo out the table
echo '<tr>';
echo '<td>Stuff</td>';
echo '<td>Stuff</td>';
echo '</tr>';
}
However, all the table rows will be exactly the same. I would like for this to happen to the rows in succession from the start:
First loop: <tr class="1">
Second loop: <tr class="2">
Third loop: <tr class="3">
Fourth loop: <tr>
Fifth loop: <tr>
etc...
I've been messing with if statements in and out of the while loop to no avail. I know that there must be a fairly straightforward solution but I just can't figure it out. Can anyone help?