Page 1 of 1
Need help with an if...else statement
Posted: Mon Jun 09, 2008 7:35 pm
by Njacobi
Thanks for the help on this. New to PHP and this should be a basic question, what I need is:
if ($input1=='logix') and ($input2=='desk')
{
echo "<p>You want $nba1</p>";
}
So if 1 = this and 2 = that, you want 3.
Thanks for the help!
Re: Need help with an if...else statement
Posted: Mon Jun 09, 2008 7:55 pm
by panic!
Code: Select all
if ($input1=='logix' && $input2=='desk')
{
echo "<p>You want $nba1</p>";
}
Re: Need help with an if...else statement
Posted: Mon Jun 09, 2008 9:33 pm
by dbemowsk
I don't get the question.
Re: Need help with an if...else statement
Posted: Tue Jun 10, 2008 6:03 am
by Njacobi
panic! wrote:Code: Select all
if ($input1=='logix' && $input2=='desk')
{
echo "<p>You want $nba1</p>";
}
Thanks, I'll give it a try, seems to be what I'm looking for. THANKS again!
*EDIT* Just tried it out, does exactly what I wanted, BIG THANKS
Re: Need help with an if...else statement
Posted: Tue Jun 10, 2008 6:30 am
by dbemowsk
I am confused. That is the code that was in your original post.
Re: Need help with an if...else statement
Posted: Tue Jun 10, 2008 6:48 am
by VladSun
dbemowsk wrote:I am confused. That is the code that was in your original post.
Code: Select all
if ($input1=='logix' and $input2=='desk')
!=
Code: Select all
if ($input1=='logix') and ($input2=='desk')
The second one has wrong PHP syntax.
@Njacobi
AND is a PHP keyword. It is logically the same as && but has different operator precedence:
http://phpbuilder.com/manual/en/languag ... precedence
Re: Need help with an if...else statement
Posted: Tue Jun 10, 2008 7:02 am
by Njacobi
Yeah, originally I put in 'and' just because that's what I wanted it to mean. Didn't think it would actually work. To make it work, all I had to do was get rid of the extra parentheses. Thanks again to everyone who helped. The script is finished and works great.
Re: Need help with an if...else statement
Posted: Tue Jun 10, 2008 4:46 pm
by dbemowsk
I see that now that I looked closer.
Re: Need help with an if...else statement
Posted: Wed Jun 11, 2008 1:54 pm
by califdon
dbemowsk wrote:I see that now that I looked closer.
's Okay. I can recommend a good ophthalmologist for you.
