Re: Alternating Table Rows, Part Deux..

From: Date: Fri, 10 May 2002 23:04:03 +0000
Subject: Re: Alternating Table Rows, Part Deux..
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-97031@lists.php.net to get a copy of this message
On 05:11 PM 5/10/2002 -0500, Shaun Thomas wrote:
This could use a few tweaks.
Ok I got it now... This exhibits the behaviour I was looking for, and, thanks to you, is much easier to read and maintain! :))) Thanks, Shaun! Glenn
        $sPrevCompany = $sColor = '';
        while ($aRow = mssql_fetch_row($stmt))
        {
          $sCompanyName = $aRow[$companyname];
        /* If our previous company name is the same as this one, don't print
           the company name, but print the data. */
                if ($sPrevCompany !== $sCompanyName)
                {
                        $sColor = ($sColor == 'FF') ? '00' : 'FF';
                        $sPrevCompany = $sCompanyName;
                } else {
                        $sCompanyName = ' ';
                }
        /* We're past our if statement, so save the previous company for
        next time. */
        print (
                "<TR BGCOLOR=#FFFF$sColor>\n".
                "\t<TD>$aRow[0]</TD>\n".
                "\t<TD>$aRow[1]</TD>\n".
                "\t<TD>$sCompanyName</TD>\n".
                "\t<TD>$aRow[2]</TD>\n".
                "\t<TD>$aRow[4]</TD>\n".
                "\t<TD>$aRow[5]</TD>\n".
                "\t<TD>$aRow[6]</TD>\n".
                "\t<TD>$aRow[7]</TD>\n".
                "</TR>\n");
        }
        print ("</TABLE>");
--- Glenn E. Sieb, System Administrator Lumeta Corp. mailto:ges@lumeta.com +1 732 357-3514 (V) +1 732 564-0731 (Fax)

« previous php.general (#97031) next »