On Fri, 22 Jun 2001, Martijn van Exel wrote:

> 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.

Doesn't look like you are resetting the $bgeven variable to a default
value (maybe you want it blank?).

May you should use the ?: operator:

foreach (@data) {
        $bg = ($cnt % 2) ? qq(BGCOLOR="#FFFFFF") : qq(BGCOLOR="#AAAAAA");

        print qq(<tr $bg> stuff stuf stuff </tr>);
        $cnt++;
}

Note also the use of the qq() double-quote like operator, so you don't
need to use backslashes.

-- Brett

                                   http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
Truth will out this morning.  (Which may really mess things up.)

Reply via email to