nested if in controller

Viewed 51

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);
    }
    
1 Answers

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

Related