theredking Posted December 6, 2007 Share Posted December 6, 2007 Hello... I'm trying to create an if statement that creates two outcomes. The else, and elseifs will also work in the same format. If I do it this way, link2 works, but link 1 becomes "www.mysite.com/scripts/1" if ($choice=="Banana") $link1 = "http://www.mysite.com/1" && $link2 = "http://www.mysite.com/2"; What am I doing wrong? Thank you in anticipation! Rory Quote Link to comment Share on other sites More sharing options...
scarlson Posted December 6, 2007 Share Posted December 6, 2007 You forgot your { and } for your if statement Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 6, 2007 Share Posted December 6, 2007 Just do this <?php if ($choice=="Banana") { $link1 = "http://www.mysite.com/1"; $link2 = "http://www.mysite.com/2"; } ?> Quote Link to comment Share on other sites More sharing options...
theredking Posted December 6, 2007 Author Share Posted December 6, 2007 Thank you!! Quote Link to comment Share on other sites More sharing options...
trq Posted December 6, 2007 Share Posted December 6, 2007 Even this is sufficient. <?php if ($choice=="Banana") $link1 = "http://www.mysite.com/1" ; $link2 = "http://www.mysite.com/2"; ?> But yeah, use braces, they make your code a lot more readable. Quote Link to comment Share on other sites More sharing options...
theredking Posted December 6, 2007 Author Share Posted December 6, 2007 Thank you all, I got myself confused trying to use the "&&" operator, clearly! :-\ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.