PHP Programing language

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

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: