[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

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.
0
andyw27
Asked:
andyw27
1 Solution
 
hernst42Commented:
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

0
 
paulp75Commented:
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

0
 
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
0
 
andyw27Author Commented:
Thanks - exactly what I was looking for
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now