Jump to content

elseif statement failing to execute his assigment.


co.ador

Recommended Posts

<?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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.