Please note this is not the frequent 'how do i colour rows alternately' question that you see across the internet.
Upon displaying a sports league table i wish for the top two rows to have a certain background colour. The next two rows to be a different shade again.
This would help highlight, for instance, that the top two teams qualify direct to the finals of a coompetition, whilst the third and fourth placed teams go into a play-off match for the third qualifying slot.
The rest of the table would just be the default colour (white).
I've Googled for hours and exhaustively tried every function i could find, all without success.
<html><body>
TABLES TEST<BR>
<H3>Group A</H3>
<?php
$conn=mysql_connect("localhost", "server", "password") or die ("could not connect");
$rs=mysql_select_db("database", $conn)or die ("could not connect to database");
$sql=stripslashes("SELECT `stage`,`team`,`p`,`pts`,`w`,`d`,`l`,`gf`,`ga`, (gf - ga) AS 'gd' FROM `lgtables` WHERE `stage` LIKE 'GP A' ORDER BY 'pts' desc, 'gd' desc");
$rs=mysql_query($sql,$conn) or die("could not execute query because ".mysql_error());
$list="<table border=\"1\" cellpadding=\"2\">";
$list.="<tr><th>Team</th>";
$list.="<th>P</th>";
$list.="<th>PTS</th>";
$list.="<th>W</th>";
$list.="<th>D</th>";
$list.="<th>L</th>";
$list.="<th>GF</th>";
$list.="<th>GA</th>";
$list.="<th>GD</th></tr>";
while($row=mysql_fetch_array($rs))
{
$list.="<tr bgcolor=\"#ffcc99\">";
$list.="<td><b>".$row["team"]."</b></td>";
$list.="<td><center><b>".$row["p"]."</b></center></td>";
$list.="<td><center><b>".$row["pts"]."</b></center></td>";
$list.="<td><center>".$row["w"]."</center></td>";
$list.="<td><center>".$row["d"]."</center></td>";
$list.="<td><center>".$row["l"]."</center></td>";
$list.="<td><center>".$row["gf"]."</center></td>";
$list.="<td><center>".$row["ga"]."</center></td>";
$list.="<td><center><b>".$row["gd"]."</b></center></td>";
$list.="</tr>";
}
$list.="</table>";
echo($list);
?>
</body></html>
I've tried various formulas based around firstly stating
$row_color1 = "#ffcc99";
$row_color2 = "#ffcc66"
Thereafter, i've tried a bewildering array of tailoring suggestions for 'alternate rows' from the internet. These have used $row_count, $mysql_num_rows, 'if' statements, 'else if' statements etc.
I finally gave up when the 'mysql_if_this_does_not_work_i'll_jump_off_a_very_high_building' function also failed to work.