codeigniter - Like query string in codelgniter -


my view page has following fields

id,name,email,gender etc.. 

i have search box , , want perform search in above fields

how write query string in ci way

controller

public function search()     {           $sql = "select * users";          $this->form_validation->set_rules('search_term', 'search_term', 'trim|xss_clean');          if ($this->form_validation->run() == true)         {              $keyword = $this->input->post('search_term');               $sql.= "where name '{$keyword }'";              $sql.= "or email '{$keyword }'";               $sql.= "or gender '{$keyword }'";                    }          $query = mysql_query($sql);     }   

read ci like query

    $keyword = $this->input->post('search_term');     $this->db->select('*');     $this->db->like('name', $keyword);     $this->db->or_like('email', $keyword);     $this->db->or_like('gender', $keyword);     $res = $this->db->get('users'); 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -