There are a couple of approaches to this, but this is how I do it -
<?
// run query and check number of rows returned
for($i = 0; $i < $num_results; $i++) {
$row = mysql_fetch_array($result);
$value1 = $row[0];
$value2 = $row[1];
$value3 = $row[2];
if ($i % 2 == 1) { //if odd index print one colour
$color = 'white';
}
else { //else print other colour
$color = 'grey';
}
echo "<tr bgcolor=\"$color\"><td>$value1</td><td>$value2</td><td>$value3</td></tr>\n";
}
?>
Hope this helps 😉