I have the following code:
<?php //Loop through array and display results in table
while ($row = sqlsrv_fetch_array($results)){
$date = $row['nc_date'];
$rowstatus = $row['nc_status'];
if ($rowstatus == 'open') {
$cssName = 'openstatus';
}else {
$cssName = 'responded';
}
?>
<tr class='<?php echo $cssName ?>'>
<td><?php echo $rowstatus?></td>
<td><?php echo $cssName?></td>
Here is an image of the table:
Notice that no matter what the row status is it assigns the cssname "responded".
Here is the information from the view source on the two rows:
<tr class='responded'>
<td>Responded</td>
<td>responded</td>
<tr class='responded'>
<td>Open</td>
<td>responded</td>
In your result I can see this :
<tr class='responded'>
<td>Open</td>
<td>responded</td>
So the $rowstatus
value is not open
but Open
. So change :
if ($rowstatus == 'open') {
by :
if ($rowstatus == 'Open') {