我已经实现了分页搜索。控制器功能`公共功能搜索(){
if($_POST)
{
$search_name=$this->input->post('search_name');
$config['base_url'] = 'search';
$config['total_rows'] = 15;//$this->registration_model->record_count();
$config['per_page'] = 4;
$config["uri_segment"] = 3;
$config['use_page_numbers'] = TRUE;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['result']=$this->institute_model->search_result($config["per_page"],$page,$search_name);
$data['links'] = $this->pagination->create_links();
$this->load->view('institute/search',$data);
}
}`
和模型功能代码是
public function search_result($limit,$start,$search_name)
{
$this->db->limit($limit, $start);
$this->db->select('user_id');
$this->db->where('category',1);
$this->db->like('first_name',$search_name);
$query = $this->db->get('registration');
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
我正在从具有 userid 和 fname 等的注册表中搜索。搜索基于用户名。它对我有用,但是当我在分页上单击第 2 页时,它会转到http://localhost/mypro/index.php/institute/search/2
并变为空白。