note 76031 added to control-structures.alternative-syntax
| From: | oly at czo dot net | Date: | Wed, 27 Jun 2007 08:59:38 +0000 |
| Subject: | note 76031 added to control-structures.alternative-syntax | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128017@lists.php.net to get a copy of this message | ||
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);
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 72.129.215.112
----
Manual Page -- http://www.php.net/manual/en/control-structures.alternative-syntax.php
Edit -- https://master.php.net/note/edit/76031
Del: integrated -- https://master.php.net/note/delete/76031/integrated
Del: useless -- https://master.php.net/note/delete/76031/useless
Del: bad code -- https://master.php.net/note/delete/76031/bad+code
Del: spam -- https://master.php.net/note/delete/76031/spam
Del: non-english -- https://master.php.net/note/delete/76031/non-english
Del: in docs -- https://master.php.net/note/delete/76031/in+docs
Del: other reasons-- https://master.php.net/note/delete/76031
Reject -- https://master.php.net/note/reject/76031
Search -- https://master.php.net/manage/user-notes.php