Page 1 of 1

if then else and font color

Posted: Mon Sep 22, 2003 2:24 pm
by ramsfield
I have a statement that compares two numbers. I would like to have the "then" portion displayed in red if $number1 is not equal to $number. I have tried several differnt things, but can not make it work. I keep getting a parse error. I am new to php so any help with a good explaination would be appreciated.

Code: Select all

<?php if ($number1 <> $number){echo money_format('%(#10n', $number1)."\n";} else {echo money_format('%(#10n', $number1)."\n";}
?>
Thanks

Posted: Mon Sep 22, 2003 2:37 pm
by JayBird
Give this a whirl :)

Code: Select all

<?php

if ($number1 <> $number) {
    echo money_format('%(#10n', $number1)."\n";
} else {
    echo "<font color="red">".money_format('%(#10n', $number1)."</font>\n";
} 
?>
Not sure if i put the correct number in red for you, if not, just swap the two echo statements.

Mark

Posted: Mon Sep 22, 2003 3:00 pm
by ramsfield
Thanks, that worked perfectly.