if then else and font color

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ramsfield
Forum Newbie
Posts: 6
Joined: Mon Sep 22, 2003 2:24 pm

if then else and font color

Post 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
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
ramsfield
Forum Newbie
Posts: 6
Joined: Mon Sep 22, 2003 2:24 pm

Post by ramsfield »

Thanks, that worked perfectly.
Post Reply