|
Contrller::
PHP复制代码
public function search_form ()
{
$this->load->library('session');
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$data['user_name']=$this->session->userdata('user_name');
$data['board_name']=$this->data_title_real;
$data['realname']=$this->data_title_index;
$data['title']=$this->data_title_search;
$data['description']=$this->data_description;
$data['more']=$this->data_more;
$this->form_validation->set_rules('search', '搜寻内容', 'required|trim|xss_clean|htmlspecialchars');
$this->form_validation->set_message('required', '<font color="red">对不起,%s栏位属於必填栏位,请重新检查。</font>');
$this->form_validation->set_error_delimiters('<div class="alert alert-error"><img src="img/error.png"> ', '</div>');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('header_view',$data);
$this->load->view('search_view');
$this->load->view('footer_view');
}
else
{
redirect ('question/view_result/'.$this->input->post('search'));
}
}
public function view_result ($key,$page=0)
{
if(!is_numeric($page)){
exit;
}
$this->load->library('session');
$this->load->helper(array('form', 'url'));
$data['user_name']=$this->session->userdata('user_name');
$data['board_name']=$this->data_title_real;
$data['realname']=$this->data_title_index;
$data['title']=$this->data_title_search;
$data['description']=$this->data_description;
$data['more']=$this->data_more;
$this->load->model('Question_model');
$this->load->database();
//Pagination
$this->load->library('pagination');
$config['base_url'] = '/index.php/question/view_result/'.urldecode($key);
$data['nums']=$config['total_rows'] = $this->Question_model->count_search(urldecode($key));
$config['per_page'] = 10;
$config['first_link'] = '第一页';
$config['last_link'] = '最後一页';
$config['full_tag_open'] = '<li>';
$config['full_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li><a>';
$config['cur_tag_close'] = '</li></a>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['next_link'] = '下一页»';
$config['prev_link'] = '«上一页';
$config['display_pages'] = FALSE;
$data['key']=urldecode($key);
$data['result']=$this->Question_model->search_question(urldecode($key),$page,$page+10);
$this->pagination->initialize($config);
$data['pagelink'] = $this->pagination->create_links();
//Pagination
$this->load->view('header_view',$data);
$this->load->view('searchResult_view',$data);
$this->load->view('footer_view');
}
复制代码
这样设计是没有分页问题了,但是又有另一个新的分页问题,让我用图片来解释
好,简单的说就是到第二页的时候,上一页的连结不见,下一页的连结却依然存在 |
|