Link to home
Start Free TrialLog in
Avatar of andyw27
andyw27

asked on

php conditional formatting?

Hello,

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>

Thanks.
Avatar of hernst42
hernst42
Flag of Germany image

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

ASKER CERTIFIED SOLUTION
Avatar of paulp75
paulp75
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Loganathan Natarajan
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
Avatar of andyw27
andyw27

ASKER

Thanks - exactly what I was looking for