note 17574 added to function.is-float
| From: | peniel at ematic dot com | Date: | Fri, 14 Dec 2001 17:58:57 +0000 |
| Subject: | note 17574 added to function.is-float | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-22617@lists.php.net to get a copy of this message | ||
I think an even simpler approach to altering background colors in table rows is turning a switch
on/off every time you write a row of data. Before writing each row, check your switch. If it is
on, use one color, otherwise use the second color. After writing each row of data, turn your switch
on/off accordingly.
Your switch will be a variable that is initialized to 1. That switch represents one of the two
colors. In the example code bellow, the switch represents a particular shade of blue. You turn the
switch on/off by multyplying it by -1.
Example:
<!-- Begin table -->
<table>
<!-- Table headings -->
<tr bgcolor="#ccffff">
<th>App. ID</th>
<th>Officer ID:</th>
<th>Date</th>
<th>Time</th>
<th>Borrower</th>
<th>Co-Borrower</th>
<th>Amount</th>
</tr>
<?php
//Start with your switch on:
$bol_bluebg = 1;
do
{
/*Decide which of the two colors you'll use based on the state of your switch:*/
if($bol_bluebg)
$str_bgcolor = "#66ccff";
else
$str_bgcolor = "#ccffff";
/* Ouput your row, using the selected background color: */
echo "<tr bgcolor=\"$str_bgcolor\">";
//Statements to display row contents go here...
echo "</tr>";
//Once you're finished with this row, switch colors:
$plbol_bluebg *= -1;
} while($dbrow = mysql_fetch_array($sqlresult));
?>
</table>
That's much simpler, isn't it?
--
http://www.php.net/manual/en/function.is-float.php
http://master.php.net/manage/user-notes.php?action=edit+17574
http://master.php.net/manage/user-notes.php?action=delete+17574
http://master.php.net/manage/user-notes.php?action=reject+17574