Zend - The PHP Company




Tables

Add Code


Function to alternate background color of rows  

Type: code fragment
Added by: anderson
Entered: 05/03/2000
Last modified: 08/12/1999
Rating: ** (5 votes)
Views: 7662
This example shows a table with 15 rows. Each row alternates the background color between light blue and dark blue.


<HTML>
<HEAD><TITLE>Alternate background color</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF">

<?    

/* Author: Christiano Anderson */
/* E-mail: anderss@zaz.com.br */
/* WebSite: http://www.anderson.eti.br */

function BackColor()    
{        
static 
$BackColorValue;
if(
$BackColorValue == "#A0BFFF")        

{    
$BackColorValue "#694FF";
}

else        
{
$BackColorValue "#A0BFFF";        
}

return(
$BackColorValue);    
}

print 
"<TABLE border="0">n";    
for(
$idrow=0$idrow 15$idrow++)

{    
$RowColor BackColor();        
print 
"<TR><TD BGCOLOR="$RowColor">";
print 
"This is the row $idrow</TD></TR>n";    
}    

print 
"</TABLE>n";
?>

</BODY></HTML>


Usage Example




Rate This Script





Search



This Category All Categories