Forum Moderators: coopster

Message Too Old, No Replies

IF AND Statement

         

Jeremy_H

1:34 am on Dec 6, 2005 (gmt 0)

10+ Year Member



I'm having a tough time getting the semantics right.

If I'm trying to show something only if two variables are true.

if ($q1=="false") && ($q2="true") {echo("stuff");}

epfantasia

1:37 am on Dec 6, 2005 (gmt 0)

10+ Year Member



Just do your two (or more) tests in parenthesis like this:

if ($q1=="false" && $q2=="true") {echo "stuff";}

Also assumed you meant $q2 == vs =

coopster

3:32 pm on Dec 6, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Nice catch, epfantasia, welcome to WebmasterWorld.

Also, if you really want to compare to the boolean [php.net] TRUE/FALSE values you shouldn't include the words in quotation marks. And welcome to WebmasterWorld to you, too, Jeremy_H.

Jeremy_H

10:08 pm on Dec 8, 2005 (gmt 0)

10+ Year Member



Thanks epfantasia! I tried combining both into the parenthesis, but my single equals sign must have messed it up! Thanks so much!

Coopster, I was only using TRUE/FALSE values as an example, but thanks for the heads up, and the welcome! ;)