Reputation: 33
Got a question. Currently working on a multiselect for a form to add users to a group, but when the user is allready in the current group i dont whant it to show in the dropdown again.
i have tried many thing but no working solution yet.
$group_id = $currentgroup;
$this->db->select('users.id, users.email');
$this->db->from('users');
$this->db->join('users_groups_data','users_groups_data.user_id = users.id','left');
$this->db->where('users_groups_data.group_id !=', $group_id);
$query = $this->db->get();
Thanks
Upvotes: 0
Views: 3467
Reputation: 16117
If your $group_id
consist on group multiselect than you need to use where_not_in
$this->db->where_not_in('users_groups_data.group_id', $group_id);
Upvotes: 2