Jump to content


Photo

Two if statements


  • Please log in to reply
3 replies to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 14 March 2006 - 03:23 AM

Hi all

Is there a way to do two if statements? Currently I use

<? if ("".$_POST['gender']."" == 'male') { print "male"; }?>

Can a sql statement be written to something like below

<? if ("".$_POST['gender']."" == 'male' & "".$_POST['age']."" == '11') { print "male"; }?>

So as well as checking the gender, I can also check the age?

Thanks in advance

Ed

#2 k.soule

k.soule
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts
  • LocationIllinois

Posted 14 March 2006 - 03:26 AM

IF ( (ARGUMENT is TRUE) && (ARGUMENT2 is TRUE) ) {
 // evaluate
}

&& is AND

|| is OR

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 14 March 2006 - 03:37 AM

Why are you using this contruct:
<?php if ("".$_POST['gender']."" == 'male') { print "male"; }?>
when this will work just as well:
<?php if ($_POST['gender'] == 'male') { print "male"; }?>

Ken

#4 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 14 March 2006 - 03:50 AM

Thanks everyone




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users