I am trying to display menus and give user rights to my users based on database value using Codeigniter. But its not working, may be the problem is in the view file. I have the following table.
Table Name: module_permission
id user_id delete add edit
1 1 0 1 1
My Controller:
$this->load->model('mod_module_permission');
$data['permit']= $this->mod_module_permission->permission($user_id);
My Model:
$this->db->select('*');
$this->db->from('module_permission');
$this->db->where('user_id', $user_id);
$getData = $this->db->get('');
if($getData->num_rows() > 0)
return $getData->result_array();
else
return null;
My View :
if ( in_array(add=>'1',$permit)) {echo "YES";} else {echo "NO";}
Could you please tell me what change in the view file could make the problem solved?
Thanks :)
add=>'1'is supposed to be an array, usearray(add=>'1')if (isset($permit['add']) && $permit['add'] == 1) { ... }