You're generating the table AFTER you've run through the loop multiple times. This means every row will be set to the same colour. You need to output the rows within the loop itself.
Something like this:
echo "<table width='200' border='2' cellspacing='0' cellpadding='0'>"
for ($i = 0; $i...