#native_company# #native_desc#
#native_cta#

Alternate row colors -simple

By Adrian Popa
on March 3, 2004

Version: 1

Type: Sample Code (HOWTO)

Category: HTML

License: GNU General Public License

Description: Litle script for alternating row colors in html tables.

<?php 
$result=mysql_query("SELECT  name FROM whatever"); 
$a=array(); 
while ($row = mysql_fetch_array($result)) 
 { 
$a[]=$row['name']; 
} 
$nr=count($a); 
print '<table> '; 
for ($i=0; $i<$nr; $i++) 
{ 
print '<tr><td>'; 
print "$a[$i]"; 
print '</td>'; 
$i++; 
print '<td>'; 
print "$a[$i]"; 
print '</td></tr>'; 
 } 
print '</table>'; 
?>