I have a PHP page that displays in a table budget vs. actual figures from a MySQL db. I want to add logic where if the actual is greater than the budget, the data is displayed in red, otherwise display in black.
[code=php]
...
while ($myrow = mysql_fetch_arr ay($result))
{
echo "<tr><td>".$myr ow["facility"]."</td>";
echo "<td align=right>$". number_format($ myrow["sw_actual"], 0, '.', ',')."</td>";
echo "<td align=right>$". number_format($ myrow["sw_budget"], 0, '.', ',')."</td>";
echo "<td align=right>$". number_format($ myrow["ben_actual "], 0, '.', ',')."</td>";
echo "<td align=right>$". number_format($ myrow["ben_budget "], 0, '.', ',')."</td>";
echo "<td align=right>$". number_format($ myrow["cl_actual"], 0, '.', ',')."</td>";
echo "<td align=right>$". number_format($ myrow["cl_budget"], 0, '.', ',')."</td>";
echo "<td align=right>".$ myrow["pd_actual"]."</td>";
echo "<td align=right>".$ myrow["pd_budget"]."</td></tr>";
}
echo "</tr></table>";
...
[/code]
I want something like this:
[code=php]
If ($myrow["sw_actual"] > $myrow["sw_budget"])
{ fontcolor=red;
}
[/code]
I tried this prior to the While code, and got an error with the 'fontcolor=red' line. Parse error: parse error, unexpected '=' in /usr/local/php_classes/swb_2007_01.php on line 88.
I tried 'fontcolor: red' as well as 'fontcolor red', but get a parse error for each.
Is my If statement incorrect? Should it be placed elswhere?
TIA,
jej1216
[code=php]
...
while ($myrow = mysql_fetch_arr ay($result))
{
echo "<tr><td>".$myr ow["facility"]."</td>";
echo "<td align=right>$". number_format($ myrow["sw_actual"], 0, '.', ',')."</td>";
echo "<td align=right>$". number_format($ myrow["sw_budget"], 0, '.', ',')."</td>";
echo "<td align=right>$". number_format($ myrow["ben_actual "], 0, '.', ',')."</td>";
echo "<td align=right>$". number_format($ myrow["ben_budget "], 0, '.', ',')."</td>";
echo "<td align=right>$". number_format($ myrow["cl_actual"], 0, '.', ',')."</td>";
echo "<td align=right>$". number_format($ myrow["cl_budget"], 0, '.', ',')."</td>";
echo "<td align=right>".$ myrow["pd_actual"]."</td>";
echo "<td align=right>".$ myrow["pd_budget"]."</td></tr>";
}
echo "</tr></table>";
...
[/code]
I want something like this:
[code=php]
If ($myrow["sw_actual"] > $myrow["sw_budget"])
{ fontcolor=red;
}
[/code]
I tried this prior to the While code, and got an error with the 'fontcolor=red' line. Parse error: parse error, unexpected '=' in /usr/local/php_classes/swb_2007_01.php on line 88.
I tried 'fontcolor: red' as well as 'fontcolor red', but get a parse error for each.
Is my If statement incorrect? Should it be placed elswhere?
TIA,
jej1216
Comment