Page 1 of 1

Conditional formating a php include

Posted: Wed Nov 07, 2007 3:16 am
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.

Posted: Wed Nov 07, 2007 1:31 pm
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?

Posted: Wed Nov 07, 2007 1:37 pm
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.