CodeIgniter Forums
How to show data only his data while he login - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: How to show data only his data while he login (/showthread.php?tid=70080)



How to show data only his data while he login - kelapamuda - 02-16-2018

Hi everyone, 
The condition is employee login by using email as username, and after login all employess data are shown in the table. But the condition  i want is this: when an employee login, he only could see his data only.

The condition now is :

    $this->datatables->select('id_users,full_name,email,address,images,salary');
   $this->datatables->from('tbl_user');

It will show up all data,,so i modified it by adding this line


    $this->datatables->select('id_users,full_name,email,address,images,salary');
   $this->datatables->from('tbl_user');
   $this->datatables->where('email=".$this->session->email."');
But no data shown up in the table, how to fix this? 

I am sorry , i already google but still confuse, i think this is about getting record by session, any help will be very usefull since  i am a beginner, thanks.


RE: How to show data only his data while he login - Wouter60 - 02-16-2018

If you are using the query builder, the syntax for the where method is like this:

PHP Code:
$this->datatables->where('email'$this->session->email); 



RE: How to show data only his data while he login - dave friend - 02-17-2018

I'm curious, what is the object $this->datatables? An alias for the usual $this->db? Or is it some custom class?


RE: How to show data only his data while he login - kelapamuda - 02-18-2018

(02-16-2018, 01:53 PM)Wouter60 Wrote: If you are using the query builder, the syntax for the where method is like this:

PHP Code:
$this->datatables->where('email'$this->session->email); 

Thank you very much, it works very well  Smile