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['vali dated'] == "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.
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['vali
{
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
are you looking something like this,
if ($row_rs_af_scs_inc1['vali dated'] == "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
if ($row_rs_af_scs_inc1['vali
{
$txtcolor = "green";
} else {
$txtcolor = "black";
}
<td><div align="center" class=<?=$txtcolor;?>>Text
ofcouse, this could be applied for <td> ... </td> also
ASKER
Thanks - exactly what I was looking for
Open in new window