Re: Alternating Row Colors in PHP........

From: Date: Sat, 08 Feb 2003 20:48:59 +0000
Subject: Re: Alternating Row Colors in PHP........
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-134893@lists.php.net to get a copy of this message
At 00:25 9-2-2003, you wrote: Hey all. I'm coming from Cold Fusion to PHP; in CF I could alternate rows with the following:
    <tr bgcolor="###Iif(((CurrentRow MOD 2) is
0),de('FFFFFF'),de('EEEEEE'))#"> Any ideas how to do this in PHP? one way would be: <?PHP $color_toggle=true; $color1='red'; $color2='white'; $output="<table border=1>"; for ($i=0;$i<10;$i++) //or any other way to walk through results { $output.= '<TR bgcolor="'.(($color_toggle)?$color1:$color2).'"><td>'.$i.' Make love not war</td></tr>'; $color_toggle=!$color_toggle; } $output.="</table>"; echo $output; ------------------------------------------------------------- or shorter: $color_toggle=false; echo('<table border=1>'); for ($i=0;$i<10;$i++) { echo('<TR bgcolor="'.(($color_toggle=!$color_toggle)?'red':'white').'"><td>'.$i.' Leve de SP</td></tr>'); } echo('</table>');

« previous php.general (#134893) next »