note 69704 deleted from control-structures.for by danbrown
| From: | danbrown@php.net | Date: | Mon, 07 Dec 2009 16:01:56 +0000 |
| Subject: | note 69704 deleted from control-structures.for by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163645@lists.php.net to get a copy of this message | ||
Note Submitter: mark at rugbyweb dot org
----
This is a handy little script for alternating row colours.
<?php
$color1="#FFFFCC"; //First Colour
$color2="none"; // Second Colour
$row_count=0; //Set row_count to 0
while($m=mysql_fetch_array($query)) //SQL query
{
$row_count++;//Counts row_count
$row_color = ($row_count % 2) ? $color1 : $color2; //Gets the colour to be used
print "<tr style='background:{$row_color}'> //Sets the row colour.
}
?>
This very handy and easy to use.