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 Link to comment https://forums.phpfreaks.com/topic/80381-solved-stuck-with-operators-easy-solution-im-sure/ 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 Link to comment https://forums.phpfreaks.com/topic/80381-solved-stuck-with-operators-easy-solution-im-sure/#findComment-407485 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/80381-solved-stuck-with-operators-easy-solution-im-sure/#findComment-407486 Share on other sites More sharing options...
theredking Posted December 6, 2007 Author Share Posted December 6, 2007 Thank you!! Link to comment https://forums.phpfreaks.com/topic/80381-solved-stuck-with-operators-easy-solution-im-sure/#findComment-407489 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. Link to comment https://forums.phpfreaks.com/topic/80381-solved-stuck-with-operators-easy-solution-im-sure/#findComment-407491 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! :-\ Link to comment https://forums.phpfreaks.com/topic/80381-solved-stuck-with-operators-easy-solution-im-sure/#findComment-407501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.