PHPBuilder - Alternate row colors -simple



RSS Twitter
Snippets Html

Alternate row colors -simple

by: Adrian Popa
|
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>'; 
?>

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Adrian Popa

Comment:



Comment:

(Maximum characters: 1200). You have characters left.