note 92825 added to language.operators.logical
| From: | daevid at daevid dot com | Date: | Tue, 11 Aug 2009 01:33:36 +0000 |
| Subject: | note 92825 added to language.operators.logical | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159302@lists.php.net to get a copy of this message | ||
If you ever need to alternate row colors for data output in a table, do this:
in your CSS put these two classes:
.dataRow1 { background-color: #DFDFDF; }
.dataRow2 { background-color: #FFFFFF; }
then in your PHP, loop over each row:
foreach ($foo_array as $foo) {
?><tr class="<?= ($dr = !$dr) ? "dataRow1" : "dataRow2"
?>"><td><?= $foo
?></td></tr><?php
}
No need to initialize $dr as by default PHP will make it a boolean "false", then each
iteration, it will toggle true/false and substitute the CSS class
----
Server IP: 64.71.164.2
Probable Submitter: 206.169.197.253
----
Manual Page -- http://www.php.net/manual/en/language.operators.logical.php
Edit -- https://master.php.net/note/edit/92825
Del: integrated -- https://master.php.net/note/delete/92825/integrated
Del: useless -- https://master.php.net/note/delete/92825/useless
Del: bad code -- https://master.php.net/note/delete/92825/bad+code
Del: spam -- https://master.php.net/note/delete/92825/spam
Del: non-english -- https://master.php.net/note/delete/92825/non-english
Del: in docs -- https://master.php.net/note/delete/92825/in+docs
Del: other reasons-- https://master.php.net/note/delete/92825
Reject -- https://master.php.net/note/reject/92825
Search -- https://master.php.net/manage/user-notes.php