PHP Programing language

adplus-dvertising
Alternating coloring table row using For loop
Previous Home Next

<html>
<head>
<title>coloring rows</title>
</head>
<body>
<?php
$row_col;
$a;
$i;
$num_dishes;
$row_col = array('purple','orange');
$a = array('HELLO HARSH',
           'HELLO MUKUND',
           'HELLO SOMARU',
		   'HELLO ADITYA');
print "<table>\n";

for ($i = 0, $num_dishes = count($a); $i < $num_dishes; $i++) {
    print '<tr bgcolor="' . $row_col[$i % 2] . '">';
    print "<td>Employee$i</td><td>$a[$i]</td></tr>\n";
}
print '</table>';
?>
</body>
</html>

outpout:
Previous Home Next