Using a query from from a MySql Database alternate the color of the table row each time through the loop.
<?php
$qry = "Select * from table";
$result = myql_query($qry);
$rs = 0; // set count of array to be 0 for first run
for($i = 0; $i < count($rs); ) {
while ($rs = mysql_fetch_array($result)) {
//divde the count by two and see if there is a remainder(odd number) and assign a color.
$bgcolor = ($i % 2) ? 'blue' : 'black';
//print results....
print "<tr>
<td bgolor=\"$bgcolor\">First Cell</td>
<td bgolor=\"$bgcolor\">Second Cell</td>
<td bgolor=\"$bgcolor\">Third Cell</td>
</tr>"; //etc
$i++;
}
}
?>
I posted this on a PHP board and it was suggested i post here. Hope this helps
someone.