【发布时间】:2016-01-12 03:35:57
【问题描述】:
//控制器
函数搜索($search = 0) {
$this->form_validation->set_rules("search", "Search", "trim|required|xss_clean");
$searchemp = $this->input->post('search');
$data['result'] = $this->main_model->search_employee($searchemp);
$data['resultcount'] = count($this->main_model->search_employee($searchemp));
//$result = $this->main_model->search_employee($searchemp);
//$this->display($this->main_model->search_employee($searchemp));
$config['base_url'] = base_url().'main/search';
$config['anchor_class'] = 'test';
$config['total_rows'] = $data['resultcount'];
$config['per_page'] = 10;
$config['num_links'] = 5;
$config['use_page_numbers'] = TRUE;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['prev_link'] = '«';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['next_link'] = '»';
$this->pagination->initialize($config);
$tmpl = array ( 'table_open' => '<table class="table table-bordered table-hover">' );
$this->table->set_template($tmpl);
//$data['searchresult']=$this->db->get($result, $config['per_page'],$search);// take record of the table
$header = array('Employee Number','Name'); // create table header
$this->table->set_heading($header);// apply a heading with a header that was created
$this->load->view('results_view',$data);
}
//模型 函数 search_employee($searchemployee) { $sql = "select Empcode, Name from spmm_employee_info where name like '%" . $搜索雇员。 "%'"; $query = $this->db->query($sql); 返回 $query->result_array(); }
当我尝试搜索并单击其他页面时,它会显示表 spmm_employee_info 上的所有数据。我想要的只是在我单击分页上的页面时显示与搜索相关的所有结果,而不是所有数据。请帮忙
【问题讨论】:
-
请给我们您的表格定义。看起来你想要某种支点,但你又漏掉了一些重要信息。