Shears
07-22-2006, 07:18 PM
Part of a script i have that outputs a html table of data from an mysql table is as follows..
$query="SELECT * FROM stats";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$username=mysql_result($result,$i,"username");
$gold=mysql_result($result,$i,"gold");
$attack=mysql_result($result,$i,"attack");
Echo "
<tr>
<td>$username</td>
<td>$gold</td>
<td>$attack</td>
</tr>
";
$i++;
}
My problem is - for the html, i would like alternate rows to be in different colours (so they can be read more easily). Such as, first row - blue coloured, second row - light blue, third row - blue, fourth row - light blue. How should i go about doing this?
Thank you for any help :)
Shears
$query="SELECT * FROM stats";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$username=mysql_result($result,$i,"username");
$gold=mysql_result($result,$i,"gold");
$attack=mysql_result($result,$i,"attack");
Echo "
<tr>
<td>$username</td>
<td>$gold</td>
<td>$attack</td>
</tr>
";
$i++;
}
My problem is - for the html, i would like alternate rows to be in different colours (so they can be read more easily). Such as, first row - blue coloured, second row - light blue, third row - blue, fourth row - light blue. How should i go about doing this?
Thank you for any help :)
Shears