Hello,
On a web page I hope to put a PHP include to retrieve data from a text file which will contain 3 statuses. RUNNING, STOPPED, PAUSED
But I can't figure out how to set conditional formatting so that for example RUNNING is displayed as green, STOPPED as red and PAUSED as yellow.
How can I do this?
Thanks in advance.
Conditional formating a php include
Moderator: General Moderators
-
digitaldan
- Forum Newbie
- Posts: 9
- Joined: Wed Oct 17, 2007 4:04 am
-
Mightywayne
- Forum Contributor
- Posts: 237
- Joined: Sat Dec 09, 2006 6:46 am
Set a variable to the result of what is in the text file.
Or have I misunderstood?
Code: Select all
if ($result == 'running')
{
echo "<font color='green'>";
}
echo "$result </font>";- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
you could use file_get_contents() to load the file into a string, then a case statement to generate your desired output.