I need to modify views in an application and I have table user privileges, with a structure like this below
id_staff | feature | capabilities
1 reports view
1 reports create
1 reports edit
2 reports view
2 reports delete
3 reports view
What I need, is where user like id_staff 3 that in reports, feature only have one capabilities, like the example he just can view, can not edit, edit, or create. Then user id 3 only sees hyperlink to view the page, he cannot see hyperlink to create, edit or delete pages.
To do that, I tried to use select query, insert that to array and then compare the array value to getting the condition like above
I have tried to code like this
<?php
$query = $this->db->query('SELECT * FROM tblstaff_permissions WHERE staff_id='.$id.'');
foreach ($query->result() as $row)
{
if($row['feature']=='reports' and $row['capabilities']=='view'){
<a href="view.php">View</a>
} elseif($row['feature']=='reports' and $row['capabilities']=='delete' ){
<a href="delete.php">Delete</a>
}
}
?>
And then the page is blank
Do you know where's the error ?
Thank you
$query->fetch_assoc()instead of$query->result()?