note 95662 deleted from function.floor by danbrown
| From: | danbrown@php.net | Date: | Thu, 14 Jan 2010 15:24:13 +0000 |
| Subject: | note 95662 deleted from function.floor by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164977@lists.php.net to get a copy of this message | ||
Note Submitter: james at brandfour dot com
----
An even simpler version of Andreas Blixt's code to create alternate table rows:
<?php
$class = ($class == 'row_odd') ? 'row_even' : 'row_odd';
?>
Example:
<?php
foreach (array_keys($table_rows) as $row) {
$class = ($class == 'row_odd') ? 'row_even' : 'row_odd';
echo '<tr class="'.$class.'">';
/* td stuff here */
echo '</tr>';
}
?>
This would produce:
<tr class="row_odd">..</tr>
<tr class="row_even">..</tr>
<tr class="row_odd">..</tr> etc...
Then your css could look something like:
tr.row_even { background:#E0E0E0;}
tr.row_odd { background:#fff;}