mercredi 23 mars 2016

two conditions in if statement codeigniter

hi i am doing this login where i do if and else statement to check if the user can access that. i have this part where two or more types of user can access this part but not all users.. i have done

<?php foreach($_SESSION['datauser'] as $a){ 

if($a->USERTYPE == '1' || $a->USERTYPE == '2'){

?>   do this

<?php }} ?>

but if it happens that for each of the condition that is true, it does the condition for example

<?php foreach($_SESSION['datauser'] as $a){ 

if($a->USERTYPE == '1' || $a->USERTYPE == '2'){

   echo 'name';

php }} ?>

if usertype == 1 and ==2 it outputs namename

i want is if usertype == 1 it will output name if usertype is == it will output also name, if usertype is both, it will also output name.

Aucun commentaire:

Enregistrer un commentaire