deed02392 Posted February 21, 2008 Share Posted February 21, 2008 <?php if (($_GET['ID']) == '18' || '9' || '13') echo ("<span class=buy>Sorry, this picture cannot be ordered currently.</span>"); else echo "<input type=image src=image/misc/btn_buynow_SM.gif border=0 name=submit alt=Click here to pay now!>"; ?> This code is meant to say, if the picture is either number 18, 9, or 13, then show they can't buy the picture, rather than the submit button if it equals anything else. however, no matter what, it ALWAYS shows that they can't buy the picture, even if ID=1 for example! I've looked at so many help website and they all show this format for else if statements. It just doesn't make sense, because, in theory, this is correct, right? Quote Link to comment Share on other sites More sharing options...
schilly Posted February 21, 2008 Share Posted February 21, 2008 I think you want: <?php if ($_GET['ID'] == '18' || $_GET['ID'] == '9' || $_GET['ID'] == '13') echo ("<span class=buy>Sorry, this picture cannot be ordered currently.</span>"); else echo "<input type=image src=image/misc/btn_buynow_SM.gif border=0 name=submit alt=Click here to pay now!>"; ?> I'm pretty sure it was reading if (id = 18) or 9 or 13. 9 is 9 and 13 is 13 so it always returns true. Quote Link to comment Share on other sites More sharing options...
duclet Posted February 21, 2008 Share Posted February 21, 2008 you could also try this if you don't like all those or case scenarios: <?php if(in_array($_GET['ID'], array(18, 9, 13)) { ... } ?> I am pretty sure the numbers don't need quote since it is in_array should be using == and not === to compare the values but if I am wrong, just check it to the string format. Quote Link to comment Share on other sites More sharing options...
deed02392 Posted February 21, 2008 Author Share Posted February 21, 2008 Thanks schilly that makes a lot more sense. Also thanks duclet, I think i put the numbers in quotes to see if it would make a difference xD Thanks again! Quote Link to comment Share on other sites More sharing options...
deed02392 Posted February 21, 2008 Author Share Posted February 21, 2008 Yahoo, it works! Thanks a lot guys. 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.