Reputation: 11
I have a 'employee' table name, then I create login page and I need to show user profile who log in. How to select particular user from id. I'm following this code, but show all user profile in database.
function empAll()
{
$q = $this->db->get('employee');
if($q->num_rows()>0)
{
foreach ($q->result() as $rows)
{
$data[]=$rows;
}
return $data;
}
Upvotes: 0
Views: 1205
Reputation: 268374
You are using the get()
method alone, without any conditions. This returns all columns and all rows. If you want records for a given user, you would use get_where()
:
$q = $this->db->get_where('employee', array('id' => $id));
You could also use where()
, if you like:
$this->db->where('id', $id);
$q = $this->db->get('employee');
Source: http://codeigniter.com/user_guide/database/active_record.html#select
Upvotes: 1