help troubleshooting foreach loop in php

Uttecetbace

New Member
I need help trying to figure out how to set my 2nd condition \[code\]($column == 'Status)\[/code\] in this foreach loop as it is not using my color_array.I created an array \[code\]color_array\[/code\] for setting values to a particular color:\[code\]$color_array = array( 'Succeeded' => 'blue', 'Failed' => 'red', 'Review Logs' => 'yellow');\[/code\]I want my column \[code\]Status\[/code\] to be color coded. My foreach loop here creates my table:\[code\]$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>';\[/code\]The first case \[code\]($column == 'Server')\[/code\] 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.
 
Back
Top