co.ador Posted January 31, 2010 Share Posted January 31, 2010 <?php $tac = isset($_GET['subt']) && is_numeric($_GET['subt'])?$_GET['subt']:null; $drop = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null; ?> <?php if(($drop != '') && ($tac == 1) || ($drop != '') && ($tac == 2)){ // this is displaying ok. } elseif(($drop != '') && ($tac == 3)) { // this script is displaying ok. } elseif(($tac == 1 ) || ($tac == 2) || ($tac == 3) || ($tac == 5)){ // this is displaying ok as well. } elseif($tac == 4){ // displaying ok. } elseif (($drop != '') && ($tac == 4)) { // But then this one is not displaying why? at the moment there is not error displaying in the screen. // it just display the html code of this condition elseif($tac == 4) //instead of the html inside of elseif (($prod != '') && ($cat == 4)) //I was wondering since ($tac == 4) condition is in both elseif statment is getting php confused? ... } ?> The comments are inside the script it self. help Don't know what's really going on. Quote Link to comment https://forums.phpfreaks.com/topic/190452-elseif-statement-failing-to-execute-his-assigment/ Share on other sites More sharing options...
premiso Posted January 31, 2010 Share Posted January 31, 2010 Order of Operations. elseif($tac == 4){ // displaying ok. } elseif (($drop != '') && ($tac == 4)) { $tac == 4 up above that, so there for the second elseif there cannot be ran as the one above it will be entered no matter what. Flip those around and it should work as you expect. Quote Link to comment https://forums.phpfreaks.com/topic/190452-elseif-statement-failing-to-execute-his-assigment/#findComment-1004622 Share on other sites More sharing options...
co.ador Posted January 31, 2010 Author Share Posted January 31, 2010 It did worked perfectly, so it means since $tac == 4 is repeated twice then it execute the first one and ignore the second. Order of operation that's called. thank you Premiso very much. Quote Link to comment https://forums.phpfreaks.com/topic/190452-elseif-statement-failing-to-execute-his-assigment/#findComment-1004628 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.