I usually make a 2 element array, and store one color in each element. Then I have a flip-flop counter, that starts at zero or one, and at the end of the loop, is set to one minus itself (thus flip-flopping between 0 and 1), and then in the loop just refer to the counter's element of the array. It goes something like this:
@colors = (black, white);
$flipflop=0;
while ($n < $nmax) {
print("<tr color=\"$colors[$flipflop]\"><td>content</td></tr>");
$flipflop = 1 - $flipflop;
}
--
If we don't change direction soon, we'll end up where we're going.