How To Make Table With Alternating Color Change Colors Each Row



How To Make Table With Alternating Color Change Colors Each Row
How To Make Table With Alternating Color Change Colors Each Row
Post Description:
Post Tags: how, to, make, table, with, alternating, color, change, colors, each, row
This Post Has Been Viewed 402 Times Since Sat Feb 23, 2008 6:48 pm Posted By hostman with 0 replies
How To Make Table With Alternating Color Change Colors Each Row
sometimes when you retrieve data from a database its a good idea to have each row in different colors to distinguish each row from another. there is a good and simple snippet you can use as an example. just copy and past this code into your text editor and save it as webune.php and then upload to your website and open it with your browser you will see the alternating colors:

<h1><a href="http://www.webune.com">WWW.WEBUBE.COM</a></h1>
<h1>Alternating Colors Table</h1>
<?
$myrow = array();
//[0] => 'site_url', [1] => 'site_url', [2] => 'http://localhost/myscripts/mypages/', [3] => 'http://localhost/myscripts/mypages/', [4] => 'WWW Address', [5] => 'WWW Address'
$myrow[0] = 'ZERO';
$myrow[1] = 'ONE';
$myrow[2] = 'TWO';
$myrow[3] = 'THREE';
$myrow[4] = 'FOUR';
$myrow[5] = 'FIVE';
$myrow[6] = 'SIX';

echo '<table border="1" cellpadding="5" cellspacing="1">';
for($i =0; $i < count($myrow); $i++) {
if($bgcolor == "E8FAFF") {$bgcolor = "FFFFFF";} else {$bgcolor = "E8FAFF";}
echo '<tr bgcolor="'.$bgcolor.'"><td>'.$i.'</td><td>'.$myrow[$i].'</td></tr>';
}
echo '</table>';
?>


the output looks like this:

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About How To Make Table With Alternating Color Change Colors Each Row




(0) Comments