Re: alternating colors

From: Date: Fri, 20 Oct 2000 00:00:07 +0000
Subject: Re: alternating colors
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-21304@lists.php.net to get a copy of this message
On Thu, 19 Oct 2000 13:32:37 -1000, Rodney Davis (rodney@wincubic.com) wrote: >I am trying to alternate table bgcolor with each iteration of >the following loop: > >print >"<td><b>One</b></td>\n<td><b>Two</b></td>\n<td><b>Three</b></td>\n</t >r>"; >foreach ($list as $row) > { > print "<tr>\n"; > print "<td> $row[one] </td>\n<td> $row[two] "; > print " </td>\n<td> $row[three] </td>\n</tr>\n<tr><td >colspan=3> >$row[four] </td>\n</tr>\n"; > print "<tr>\n<td colspan=3> $row[five] </td>\n"; > print "</tr>\n"; > } >print "</table>"; > >So that every three rows will be a single grouped color different >from the >next three rows. >Does anyone know how to do this ? something like this should work: $colors=array("red","white","blue"); $i=0 for(;;){?> <tr bgcolor="<?echo $colors[$i++%3]?>"> <td>blah blah</td> </tr> <?} - Mark

« previous php.general (#21304) next »