I am creating a table (stats_1) dynamically and would like to have each row of different background color. So far, all the lines have the same background color.
I have the following php code that prints echoes out and statements:
$keys = array('Col1', 'Col2','Col3','Col4','Col5','Col6','Col7');
echo '<table id="stats_1"><tr>';
foreach ($keys as $column)
echo '<th>' . $column . '</th>';
echo '</tr>';
foreach ($data as $row){
echo '<tr class="alt">';
foreach ($keys as $column)
if (isset($row[$column])){
echo '<td>' . $row[$column];
} else {
echo '<td>' . '' . '</td>';
}
}
echo '</table>';
I need some help making EVERY OTHER ROW ($row) have a different COLOR, but don't know how to do that programmatically with the echo statement. So, it would alternate printing between:
echo '<tr class="alt">'; or echo '<tr>';
I define that in a class:
#stats_1 tr.alt td
{
color:#000000;
background-color:#E0E0FF;
}
THanks for your help/input.