change display color in table if criteria is true

I have information pulling from the database. I have a Select statement where is dates are in certain ranges the job has a certain status. I have colored the columns in the table but instead of this I would like to color the cell depending on the status. So if it is in 'Production' it would be red. 'Shipped' then blue and so on....Not sure if I can add it to my Select where is prints to the table when case is true or if I need an IF statement. Any help appreciated. Code and screenshot attached.
index.php
print-screen.jpg
j8547Asked:
Who is Participating?
 
Julian HansenCommented:
Change your Row code to this
<tr>
	<td><?php echo  $record['Job Number'] ?></td>
	<td><?php echo $record['Description'] ?></td>
	<td><?php echo date('d/m/Y', strtotime($record['Start Date'])) ?></td>
	<td><?php echo date('d/m/Y', strtotime($record['Projected Finish Date'])) ?></td>
	<td class="status <?php echo strtolower($statusToday);?>"><?php echo $statusToday ?></td>
	<td class="status <?php echo strtolower($statusTomorrow); ?>"><?php echo $statusTomorrow ?></td>
	<td class="status <?php echo strtolower($statusNextday); ?>"><?php echo $statusNextday ?></td>
	<td class="status <?php echo strtolower($statusNextday1);?>"><?php echo $statusNextday1 ?></td>
	<td class="status <?php echo strtolower($statusNextday2);?>"><?php echo $statusNextday2 ?></td>
</tr>

Open in new window

Add CSS
td.status {
  font-weight: bold;
}
td.status.complete {
  background-color: #ff0000;
}
td.status.production {
  background-color: #00ff00;
}
td.status.shipped {
  background-color: #0000ff;
}

Open in new window


Note: inline styles as you have them currently are better handled with CSS.
attributes like bgcolor have been deprecated.
0
 
Jan LouwerensSoftware EngineerCommented:
Instead of hard-coding the colors in the html, you should just give each table cell a class (which would be determined rhe same way as the table cell contents), then use css to define the color of the table cell.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.