I have some issue when I want to search some data from my database using Codeigniter. I want to select data where the level is 0 or 3 and status is 1.
tb_user_data :
------------------------------------
| username | name | level | status |
------------------------------------
| abb | ab | 0 | 1 |
| abc | aa | 1 | 1 |
| aac | bb | 2 | 1 |
| acc | cc | 3 | 1 |
------------------------------------
script select data
$data["adm"] = $this->db
->where("level", "0")
->or_where("level", "3")
->where("status", "1")
->get('tb_user_data')
->result_array();
When I try to search it by the name, the script doesn't work.
Try this:
$data["adm"] = $this->db->where_in('level', array('0','3'))
->where("status", "1")
->get('tb_user_data')->result_array();