This is the controller search.php
public function login()
{
$email=$this->input->post('email');
$password=md5($this->input->post('password'));
$result=$this->search_model->login($email,$password);
if(!$result) {
$this->index();
}
else {
$this->session->set_userdata('user_id',$email);
$seid=$this->session->userdata('user_id');
$data['result'] =$this->search_model->autocomplete();
$this->load->view('pagination_view',array('result' => $result));
}
}
===========================Model=========================================
public function autocomplete($like) {
$this->db->select('name');
$this->db->from('tbl_reg');
$this->db->like('name', $like);
// $this->db->where('status', ACTIVE);
$q = $this->db->get();
if ($q->num_rows() > 0) {
return $q->result();
}
}
in controller search.php what argument is added to the autocomplete()
. the code is
$data['result'] = $this->search_model->autocomplete();
I got an error like this Severity: Warning
Message: Missing argument 1 for search_model::autocomplete(),
and another error message like
Undefined variable: like
Whats the solution for this problem?
You need to pass argument in your model function
$this->search_model->autocomplete($YOUR_LIKE_VARIABLE);// pass your like variable here
Because in model file you use
public function autocomplete($like) {
you are supposed to pass the like variable as argument to your model function
In your controllers
$like = "matching word"; // replace this with your value;
$data['result'] =$this->search_model->autocomplete($like);
If you not passing $like variable then How your model will search.
$like='any text' // this would be your keyword for which you are doing auto complete process, Like any name or anything.
$data['result'] = $this->search_model->autocomplete($like);