note 76031 deleted from control-structures.alternative-syntax by mgf
| From: | mgf@php.net | Date: | Thu, 28 Aug 2008 12:45:22 +0000 |
| Subject: | note 76031 deleted from control-structures.alternative-syntax by mgf | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143921@lists.php.net to get a copy of this message | ||
Note Submitter: oly at czo dot net
----
3 Lines to make table row colors alternate. Could be used for other applications as well.
<?
//1. Initialize alternating variable.
$alt_color=true;
while($row=mysql_fetch_array($result)){
//2. If alt var true set one color if false set the other.
echo (($alt_color) ? "<tr bgcolor=\"#ffffff\">\n" : "<tr
bgcolor=\"#D9E5F1\">\n");
echo "<td>echo $row['id'];;</td>\n";
echo "</tr>\n";
//3. Alternate the variable value;
(($alt_color) ? $alt_color=false : $alt_color=true);
}
?>