RE: [PHP] Alternate row color

From: Date: Wed, 09 Aug 2000 17:15:40 +0000
Subject: RE: [PHP] Alternate row color
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-10964@lists.php.net to get a copy of this message
And what's the value for $ilim ? On Wed, 9 Aug 2000, Rolle, Ted wrote: trolle: I've frequently been accused of taking the "scenic route" in coding. trolle: Here's one that allows you to alternate as many colors as you wish: trolle: trolle: $color[]="red"; trolle: $color[]="white"; trolle: $color[]="aabbbcc"; /* A favorite of mine. The others are garish */ trolle: . trolle: . trolle: . trolle: $colorlim = count($color); trolle: trolle: for ($i=0; $i < $ilim; ++$i) { trolle: $bg = $color[$i % $colorlim]; /* This may not work as a subscript; trolle: ergo the separate line */ trolle: <tr bgcolor=$bg>.... trolle: } trolle: trolle: -----Original Message----- trolle: From: Tyler Longren [mailto:tyler.longren@midiowa.net] trolle: Sent: Tuesday, August 08, 2000 8:06 PM trolle: To: PHP-General trolle: Subject: [PHP] Alternate row color trolle: trolle: trolle: Hello, trolle: trolle: How could I alternate table row colors by using a for or while loop? It trolle: can't be that hard. I just can't grasp it. I will be gettting the rows trolle: out of a MySQL db, and I want to alternate the colors on a page. Any trolle: examples? trolle: trolle: Regards, trolle: -- ------------------------------------------------ Yurais Fernández Leal, Systems Administrator Public Health Network Santiago de Cuba yurais@medired.scu.sld.cu http://www.scu.sld.cu/ Phone: (53) 226-54204 (home) (53) 226-51556 ICQ: 33792610 ------------

« previous php.general (#10964) next »