Re: row colours

From: Date: Sat, 05 Jun 2004 16:17:11 +0000
Subject: Re: row colours
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-187687@lists.php.net to get a copy of this message
On Sat, 2004-06-05 at 11:21, James Kaufman wrote: > $bgcolor = ($i % 16 > 8) ? #eeeeff : #ffffff; > print "<tr > > bgcolor='$bgcolor'><td>$item_1</td><td>$item_2</td><td>$item_4</td><td><cen > ter>$item_5</center></td></tr>\n"; You probably want to do: $bgcolor = (($i % 16) > 7) ? #eeeeff : #ffffff; Since $i % 16 will rotate from 0 - 15. This will work assuming $i starts at 0. If not then you should do: $bgcolor = ((($i - $x) % 16) > 7) ? #eeeeff : #ffffff; Where $x is whatever value $i started at. However, I would recommend using a new counter that starts a 0 and is incremented at the end of your loop. Alternatively you could do: print "<tr bgcolor='#ffffff'><td>$item_1</td><td>$item_2</td><td>$item_4</td><td><center>$item_5</center></td></tr>\n"; if ($i % 8 == 7) { print "<tr><td colspan='4'></td></tr>\n"; } which would keep them the same color and add a blank row after every eighth; again adjust $i as necessary to fit. -- Adam Bregenzer adam@bregenzer.net http://adam.bregenzer.net/

« previous php.general (#187687) next »