semicolon after close brace is probably the problem. Try:
$cnt = 0;
foreach (@data)
{
$background = ($cnt % 2) ? 'bgcolor="#cccccc"' : 'bgcolor="#ffffff"';
print('<tr '.$background.'>'.$_.'</tr>');
$cnt++;
}
>>> Martijn van Exel <[EMAIL PROTECTED]> 06/22/01 01:15pm >>>
>On Fri, 22 Jun 2001, Martijn van Exel wrote:
>
>> Why the $! does
>>
>> (int($cnt/2) == ($cnt/2))
>>
>> not return TRUE for an even $cnt and FALSE for an odd $cnt ?
>
>Use the modulus operator %. It returns a remainder of a division -- in
>the case of modulus 2, it will return either 0 or 1.
>
Thanks, this should work. Trying to implement:
foreach (@data)
{
if ($cnt % 2) {$bgeven = " BGCOLOR\=\"\#FFFFFF\""};
print("<tr".$bgeven.">"....cut irrelevant part.....);
$cnt++;
}
H'm..
This yields a table with the first row ($cnt=0) using standard
BGCOLOR and *all* following rows displaying with BGCOLOR=#FFFFFF....
So my first throw at a check for 'even-ness' was probably all right,
the problem is somewhere else.
Any suggestions?
--
Martijn van Exel, [EMAIL PROTECTED]
WEBkitchen
Waterstraat 11
3511 BW Utrecht
tel/fax 030-6701818
http://www.webkitchen.nl
This e-mail and any files transmitted with it are confidential
and solely for the use of the intended recipient.
ONdigital plc, 346 Queenstown Road, London SW8 4DG. Reg No: 3302715.