我在这里到处搜索关于显示不同导航菜单取决于用户类型。我的数据库用户表有一个名为" user_type"的字段。以下是我的想法。问题是我不知道如何执行它。
if($user_type == 'Admin') {
$this->load->view('navbar-menu');
} else if($user_type == 'Client') {
$this->load->view('navbar-menu-client');
} else {
$this->load->view('navbar-menu-normal');
}
答案 0 :(得分:0)
also make a session code for it and pass this user_ID and compare in your database and get the user_type in your table.
i have make simple code for your .
make a condtoller in your folder with (My_controller.php) this name and than after go yo your browser and run this URL : HOSTNAME/index.php/My_controller/index
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class My_controller extends CI_Controller {
public function my_controller()
{
parent::__construct();
}
function index()
{
$where = array('user_ID' => $this->session->userdata['login_ID']);
$user_type = $this->yourmodelname->yourfunctioname($where);
if($user_type == 'Admin')
{
$this->load->view('navbar-menu');
}
else if($user_type == 'Client')
{
$this->load->view('navbar-menu-client');
}
else
{
$this->load->view('navbar-menu-normal');
}
}
}
?>