1

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 and 3 with status 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 working. Or I got some wrong script or anything else?

thank you

Imam Nur
  • 59
  • 7

1 Answers1

1

Try this:

$data["adm"] = $this->db->where_in('level', array('0','3'))
                        ->where("status", "1")
                        ->get('tb_user_data')->result_array();
Ankit Singh
  • 1,502
  • 1
  • 11
  • 22