On Fri, 22 Jun 2001, Martijn van Exel wrote:
> Thanks, this should work. Trying to implement:
>
> foreach (@data)
> {
> if ($cnt % 2) {$bgeven = " BGCOLOR\=\"\#FF\""};
> print(""cut irrelevant part.);
> $cnt++;
> }
>
> H'm..
>
> This yields a table with the first row ($cnt=0) using st
semicolon after close brace is probably the problem. Try:
$cnt = 0;
foreach (@data)
{
$background = ($cnt % 2) ? 'bgcolor="#cc"' : 'bgcolor="#ff"';
print(''.$_.'');
$cnt++;
}
>>> Martijn van Exel <[EMAIL PROTECTED]> 06/22/01 01:15pm >>>
>On Fri, 22 Jun 2001, Martijn van Exel
>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.
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.
-- Brett
Works for me! Have you tried using:
$odd_even = ($cnt % 2) ? 'ODD' : 'EVEN';
>>> Martijn van Exel <[EMAIL PROTECTED]> 06/22/01 11:56am >>>
Dear subscribers.
Why the $! does
(int($cnt/2) == ($cnt/2))
not return TRUE for an even $cnt and FALSE for an odd $cnt ?
What _is_ the way to test for od
On Fri, 22 Jun 2001, Martijn van Exel wrote:
> What _is_ the way to test for odd/even then!?
A common way is:
$number % 2
which will be 1 for odd numbers and 0 for even numbers.
--
Mother is the name for GOD on the lips and
hearts of all children. - Eric Draven
Dear subscribers.
Why the $! does
(int($cnt/2) == ($cnt/2))
not return TRUE for an even $cnt and FALSE for an odd $cnt ?
What _is_ the way to test for odd/even then!?
Background: I am trying to do alternating BGCOLOR in s in order
to improve legibility of a long table.
Please CC, I am on di