I need help trying to figure out how to set my 2nd condition ($column == 'Status)
in this foreach loop as it is not using my color_array.
I created an array color_array
for setting values to a particular color:
$color_array = array(
'Succeeded' => 'blue',
'Failed' => 'red',
'Review Logs' => 'yellow'
);
I want my column Status
to be color coded. My foreach loop here creates my table:
$keys = array('Server', 'Target','Set','Time', 'Length','Size','Status');
echo '<table id="stats_1"><tr>';
foreach ($keys as $column) {
echo '<th>' . $column . '</th>';
}
echo '</tr>';
foreach ($data as $row){
foreach ($keys as $column){
if (isset($row[$column])){
if ($column == 'Server'){
echo '<td> <a href="' . $server_array[$row[$column]] . '">' . $row[$column] . '</a></td>';
} else {
echo '<td>' . $row[$column] . '</td>';
}
if ($column == 'Status'){ //2nd condition here
echo '<td> <font color="' . $color_array[$row[$column]] . '">' . $row[$column] . '</font></td>';
} else {
echo '<td>' . $row[$column] . '</td>';
}
} elseif ($column == 'Length') {
echo '<td> n/a </td>';
} elseif ($column == 'Size') {
echo '<td> n/a </td>';
} else {
echo '<td> </td>';
}
}
}
echo '</table>';
The first case ($column == 'Server')
works fine, but after adding the 2nd case, i would think it would work the same way? but its not...Somehow my logic is wrong. How do I get the 2nd case to work? Thanks.