RE: [PHP] Alternate Colors in Rows
| From: | Daevid Vincent | Date: | Wed, 03 Oct 2007 19:57:40 +0000 |
| Subject: | RE: [PHP] Alternate Colors in Rows | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-262706@lists.php.net to get a copy of this message | ||
Add this to your default.css file... Or to the page...
<style>
TR.dataRow1 { background-color: #e8f5f7; } /* light */
TR.dataRow2 { background-color: #dce8ea; } /* dark */
</style>
Then just do this:
<TR class=<?php echo ($r = !$r) ? "dataRow1" : "dataRow2"; ?> >
Forget all that $i++ and (mod) % stuff...
And NEVER hardcode the colors in the page. Use CSS !
Adjust to use a DIV as needed.