This is a very simple tutorial about how to give different color on Even and Odd lines in PHP
[php] <?php $evenOdd = 1; for ($x = 0; $x < 10; $x++) { if ($evenOdd == 3) { $evenOdd = 1; } if ($evenOdd == 1) { echo "<div style=\"background-color:#e9e9e9;padding:8px 0 8px 8px\">"; echo "Test Line " . $x; echo "</div>"; } else { echo "<div style=\"background-color:#d4d4d4;padding:8px 0 8px 8px\">"; echo "Test Line " . $x; echo "</div>"; } $evenOdd = $evenOdd + 1; } ?> [/php]
You can either see the demo or download the project files
Why?? (($number % 2 == 0) ? ‘even’:’odd’)