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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.