jimitodd
-
Posts
3 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by jimitodd
-
-
Thanks I've tried these two options but both give syntax errors.
first on the if and style lines.
second on the if line
first
<?php$st=(echo $rows['status']);if ($st="On Time") { style="color:green"; }elseif ($st="Delayed") { style="color:orange"; }elseif ($st="Cancelled") { style="color:red"; }?>
second..
<?phpecho $rows['status'];if (['status']="On Time") { style="color:green"; }elseif (['status']="Delayed") { style="color:orange"; }elseif (['status']="Cancelled") { style="color:red"; } else { style="color:black"; }?>
-
I have an update form uploading to mysql and a php/html page downloading to a table on another page.
What I would like is the website to colour code the status on the public page depending on the input form.
I've tried alsorts of code on the form, the results and a stylesheet.
Any help or suggestions welcome.
Thanks
Here's the relevant bit of the form code.
<select name="status" type="text" id="status" value="<? echo $rows['status']; ?>"> <option style= "color:green" value="On Time">On Time</option> <option style= "color:orange" value="Delayed">Delayed</option> <option style= "color:red" value="Cancelled">Cancelled</option> </select>
and this is the cell from the page.
<td>Status</td><td><?php echo $rows['status']; ?></td>
Conditional Formatting
in PHP
Posted
Got there eventually.
I think I was trying to over complicate it, I had a day off and came back with a fresh pair of eyes.
<?phpif ($rows['status'] == "On Time") {echo '<font color="green">On Time</font>';} elseif ($rows['status'] == "Delayed") {echo '<font color="orange">Delayed</font>';} else {echo '<font color="red">Cancelled</font>';} ?>