RE: [PHP] Alternate row color

From: Date: Wed, 09 Aug 2000 16:07:36 +0000
Subject: RE: [PHP] Alternate row color
Groups: php.general 
Request: Send a blank email to php-general+get-10953@lists.php.net to get a copy of this message
I've frequently been accused of taking the "scenic route" in coding. Here's one that allows you to alternate as many colors as you wish: $color[]="red"; $color[]="white"; $color[]="aabbbcc"; /* A favorite of mine. The others are garish */ . . . $colorlim = count($color); for ($i=0; $i < $ilim; ++$i) { $bg = $color[$i % $colorlim]; /* This may not work as a subscript; ergo the separate line */ <tr bgcolor=$bg>.... } -----Original Message----- From: Tyler Longren [mailto:tyler.longren@midiowa.net] Sent: Tuesday, August 08, 2000 8:06 PM To: PHP-General Subject: [PHP] Alternate row color Hello, How could I alternate table row colors by using a for or while loop? It can't be that hard. I just can't grasp it. I will be gettting the rows out of a MySQL db, and I want to alternate the colors on a page. Any examples? Regards, -- Tyler Longren [Web Development] Premier Visual Services http://www.pvs2000.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#10953) next »