php conditional formatting?


I have if statement that i testing for a value in a database.  this works fine when I want to output some text based upon the result (just use the echo command)

I want to change this slightly so that I can change the color of text.

This is what I have at the moment.

if ($row_rs_af_scs_inc1['validated'] == "Yes")
echo "Validated";

this is the code that displays the text that I want to change the color (or ccs style) on:

<td><div align="center">Text to change color</div></td>

Who is Participating?
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.

You mean something like that, or explain a little more the context, the question is not really understandable.
if ($row_rs_af_scs_inc1['validated'] == "Yes")
echo "<font color=\"green\">Validated</font>";

Open in new window

is this what your after

<td><div align="center" <?php if ($row_rs_af_scs_inc1['validated'] == "Yes")
{ ?><style="color: #000000"><?php } ?>Text to change color</div></td>

Open in new window


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
Loganathan NatarajanLAMP DeveloperCommented:
are you looking something like this,

if ($row_rs_af_scs_inc1['validated'] == "Yes")
     $txtcolor = "green";
} else {
     $txtcolor = "black";

<td><div align="center" class=<?=$txtcolor;?>>Text to change color</div></td>

ofcouse, this could be applied for <td> ... </td> also
andyw27Author Commented:
Thanks - exactly what I was looking for
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

From novice to tech pro — start learning today.