I am new to Codeigniter and seeking some help here.
I am making a test app with pagination. It works fine until the first result but when clicked on 'Next' or 'Any Pagination' tells no results were found.
I think it calls for url alright but don't know what else is the problem.
http://localhost/admin/search/search-results/2
My controller:
public function pagination(){
$keyword = $this->input->post('search[1]');
$main_keyword = $this->search_model->get_city_id_by_input($keyword);
$config['base_url'] = base_url().'search/search-results/';
$config['total_rows'] = $this->search_model->total_number_of_rows($main_keyword);
$config['per_page'] = 1;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = $this->search_model->total_number_of_rows($main_keyword);
$config['cur_tag_open'] = ' ';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
$data['results'] = $this->search_model->get_search_results($main_keyword, $config['per_page'], $this->uri->segment(3));
$this->load->view('view',$data);
}
Model:
function get_city_id_by_input($keyword){
$this->db->select('id');
$this->db->from('vbc_city');
$this->db->where('v_city_name', $keyword);
$query = $this->db->get();
$query_result = $query->result_array();
return $query_result();
}
public function total_number_of_rows($main_keyword) {
$this->db->select('vbc_item_id');
$this->db->from('vbc_vacation_item_attri');
$this->db->where('v_item_city', $main_keyword);
$query = $this->db->get();
return $query->num_rows();
}
public function get_search_results($main_keyword, $perpage, $offset) {
$this->db->select('*');
$this->db->from('vbc_vacation_item_attri');
$this->db->where('v_item_city', $main_keyword);
$this->db->limit($perpage, $offset);
$query = $this->db->get();
$result = $query->result();
return $result;
}
Please help.