RE: [PHP] Two color rows in table inside while iteration
| From: | Daevid Vincent | Date: | Fri, 30 Apr 2010 07:40:52 +0000 |
| Subject: | RE: [PHP] Two color rows in table inside while iteration | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304767@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> while(foo){
> $tr = (0 == $trColor % 2)? "#E8E8E8" : "#FFFFFF";
> echo "<tr style=\"background-color:".$tr."\">";
> ...
Don't do this modulus (%) math!!!! Just toggle a boolean!!
<tr class="<?= ($r = !$r) ? "dataRow1" : "dataRow2"; ?>">
Attachment: [application/x-pkcs7-signature] smime.p7s
Attachment: [application/x-pkcs7-signature] smime.p7s