RE: [PHP] Seems Simple enough
| From: | Larry Brown | Date: | Mon, 26 Jan 2004 16:52:26 +0000 |
| Subject: | RE: [PHP] Seems Simple enough | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-175782@lists.php.net to get a copy of this message | ||
you need one of the to if's to be either $Balance >=10000 elseif($Balance <
1000) or $Balance > 10000 elseif($Balance <= 10000). Yours has the first
saying everything equal to or greater than 10001 which 10000 is not else
everything less than or equal to 9999 which 10000 is not. =)
Larry
-----Original Message-----
From: Christopher J. Crane [mailto:ccrane@ikon.com]
Sent: Monday, January 26, 2004 11:29 AM
To: php-general@lists.php.net
Subject: [PHP] Seems Simple enough
I have these lines of code, that I thought was simple enough, but it doesn't
work how I thought.
The Variable $Balance is set to 10000 in the database, and I thought it
would be outputed as purple or the be found true of the "else" part of the
code. It comes out as red or the "elseif" part of the code.
if($Balance >= 10001) { echo "<font
color=\"green\">\$$Balance</font><br>\n"; }
elseif($Balance <= 9999) { echo "<font
color=\"red\">\$$Balance</font><br>\n"; }
else { echo "<font color=\"purple\">\$$Balance</font><br>\n";
}
I originally had it as follows, but that didn't work either.
if($Balance > 10000) { echo "<font
color=\"green\">\$$Balance</font><br>\n"; }
elseif($Balance < 10000) { echo "<font
color=\"red\">\$$Balance</font><br>\n"; }
else { echo "<font color=\"purple\">\$$Balance</font><br>\n";
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php