PHP

PHP: Even Odd line color Simple tutorial

PHP Even Odd line color Simple tutorial

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

DEMODOWNLOAD

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *