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>');


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to