Conditional formating a php include

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
digitaldan
Forum Newbie
Posts: 9
Joined: Wed Oct 17, 2007 4:04 am

Conditional formating a php include

Post by digitaldan »

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.
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

Set a variable to the result of what is in the text file.

Code: Select all

if ($result == 'running')
{
echo "<font color='green'>";
}

echo "$result </font>";
Or have I misunderstood?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

you could use file_get_contents() to load the file into a string, then a case statement to generate your desired output.
Post Reply