Re: Question concerning SWITCH and Comparisons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think this may work...but doing some debbuging I suggest:
case ($qty>=1600 and $qty< 2400): //$qty is less than 2400
and I modified the semi-colon of this part of code:
case ($qty >= 2400): //$qty is greater than or equal to 2400

I tried your code and It works!

Hope this helps,

Alex
----- Original Message ----- 
From: "Tony Devlin" <tdevlin@xxxxxxxxxxxxx>
To: "Php-Windows" <php-windows@xxxxxxxxxxxxx>
Sent: Thursday, November 11, 2004 2:35 PM
Subject:  Question concerning SWITCH and Comparisons


> If my understanding of SWITCH is correct, it stops at the first case
> that
> matches the result, correct?
> 
> So then.. If I have a switch as such;
> 
> switch($qty){
> 
> case ($qty < 1600): //$qty is less than 1600
>   do something
> break;
> 
> case ($qty < 2400): //$qty is less than 2400
>   do something
> break;
> 
> case ($qty >= 2400); //$qty is greater than or equal to 2400
>   do something
> break;
> 
> default:
>  do something
> break;
> }
> 
> Then assuming $qty = 800, it should stop at the first case? right?
> 
> a $qty of 1601 should stop at the second case?
> 
> and a qty of greater than or equal to 2400 should stop at the last case?
> 
> Am I correct with my switch statement then?
> 
> My desired result is;
> 
> If quantity is less than 1600 set price = whatever;
> or if quantity is equal to 1600 and less than 2400 set price = whatever,
> or finally if quantity is equal to or greater than 2400 set price =
> whatever.
> 
> I'm having difficulties for whatever reason to come up with a proper
> comparison
> for the switch to work as described.  Can someone help me iron out this
> small problem?
> 
> 
> Much thanks for the help,
> 
> Tony D.
> 

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux