Guest CableGuy Posted January 13, 2010 Report Posted January 13, 2010 Hi, Quite funny that I do not know the answer to this, But I've seen a few sites that have roster's with 1 row being 1 color and another being another. While the roster is all automated, How i can i create it so it knows to make like the next row a certain color and the one after that another. For an example, Check below; Quote
Administrators simpilot Posted January 13, 2010 Administrators Report Posted January 13, 2010 This is what I do <style> .row0 {background-color: #E0E0E0;} .row1 {background-color: #ffffff;} </style> $class = 0; foreach ($results as $result) { echo '<tr class="row'.$class.'"><td>Your data</td></tr>'; $class = 1 - $class; } Quote
Administrators Nabeel Posted January 13, 2010 Administrators Report Posted January 13, 2010 I do: <?php $row_int = 0; foreach($rows as $row) { $class = ($row_int++ % 2 == 0) ? 'row0' : 'row1'; echo '<tr class="'.$class.'">...</tr>'; } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.