Re: [PHP] switch()

2006-08-29 Thread John Meyer

[EMAIL PROTECTED] wrote:

Why do you want to use a switch in this particular instance.  You're
comparing apples and oranges (in this case, col_1 and col_2).  You use
swithc to evaluate one variable against a number of choice, not multiple
variables against variable choices.




I'm not comparing apples and oranges - just have such a "case", but looks
like I'm wrong about using switch() on wrong place. Just thought it could
do it.
:)
  



What you're saying in that case is either col_1 evaluates to value1 or 
col_2 evaluates to value2.  Unless you have some program logic to 
prevent both from being true, you are comparing apples and oranges.  And 
any time col_1, evaluates to true, the "break" keyword will stop your 
switch ladder.  Remove break, and that won't happen.  of course, if you 
do that, then the question arises about why you are using a switch 
ladder in the first place.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: [PHP] switch()

2006-08-29 Thread afan
> Why do you want to use a switch in this particular instance.  You're
> comparing apples and oranges (in this case, col_1 and col_2).  You use
> swithc to evaluate one variable against a number of choice, not multiple
> variables against variable choices.
>

I'm not comparing apples and oranges - just have such a "case", but looks
like I'm wrong about using switch() on wrong place. Just thought it could
do it.
:)

thanks.




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: [PHP] switch()

2006-08-29 Thread John Meyer

[EMAIL PROTECTED] wrote:

I have something like this:



when I tried to use swiitch()


it will give me only the first true case. if $result['col_1'] == 'value_1'
is true 2nd case will never be executed?
Does it mean I CANNOT use switch() in this case?

-afan

  
Why do you want to use a switch in this particular instance.  You're 
comparing apples and oranges (in this case, col_1 and col_2).  You use 
swithc to evaluate one variable against a number of choice, not multiple 
variables against variable choices.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]