Basically what i did with mine (and thanks Fou-Lu for the official tech term zebra striping
The easiest way i found is to set your first color before the record loops start.
Then as you finish the output of each row, check the color, if the color is color 1 then change it to color 2, if it is color 2 change it to color 1. That way each row is a different color.
rowa and rowb are set as class in css or you can set them in the file your in using style
background-color:#FFFFFF; /* white */
background-color:#000000; /* black */
set your rowb color and rowa colors before the loop starts, then at the beginning of the loop before the output of the first row, set $switchrow to either rowa or rowb,
<tr class="<?=$switchrow;?>" >
then at the end of the loop before the next record try something like this.
//switch the row color if need to
if($switchrow == "rowb")
$switchrow = "rowa";
$switchrow = "rowb";