简体   繁体   中英

nested if in controller

i have controller with nested if to show different view if condition occur my problem it show me first view (view_admin) if condition happen only the first condition otherwise if any conditions like "accountant" or "support" occurs it give me last else view (view-ask) any help

code:

   if($user_info->privilege == "admin"){
    $this->load->view('dash/view_admin',$data);
    
    }
    else if($user_info->privilege == "accountant"){

    $this->load->view('dash/view_accountant',$data);
    
    }
    else if($user_info->privilege = "support"){

    $this->load->view('dash/view_support',$data);
    }
    
    else {

    $this->load->view('dash/view-ask',$data);
    }
    

In your 3rd condition you are missing "="

else if($user_info->privilege = "support"){

    $this->load->view('dash/view_support',$data);
    }

make this

 else if($user_info->privilege == "support"){

    $this->load->view('dash/view_support',$data);
    }

try this.

if the problem is not solved var_dump($user_info->privilege); and add output to question

Goodluck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM