/ Published in: PHP

This is a simple way to stripe alternate rows of output or to do anything different as I process each alternate row. Typically, I set the element's class to "myEvenRow" or "myOddRow" then output the data just after the IF statement.
I found this full example at nullislove.com. The page also has a Ruby example. Full props to them.
I found this full example at nullislove.com. The page also has a Ruby example. Full props to them.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // PHP version $i = 0; // have_rows_to_output is a stand-in for your loop's code while (have_rows_to_output) { output_even_style_row; } else { // it's an odd number output_odd_style_row; } $i++; } ?>
URL: http://www.nullislove.com/2007/05/09/zebra-striping/
Comments
