我有一个问题,当我搜索分页编号仍然保留在网址结果显示没有resuts。例如,当我点击一个分页链接时,我的网址看起来像这个例子/ index.php / example / info / 10然后当我搜索时,网址现在的url看起来像这个例子/ index.php / example / info / 10? search = word
我如何解决此问题
public function info($offset=0)
{
$this->load->library('pagination');
$search = $this->input->get('search');
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
if($this->input->get('search')){
$count = $this->ticketing_mdl->count_all_ticket();
$config['total_rows'] = $count;
$config['suffix'] = '?' . http_build_query($_GET, '', "&");
$config['base_url'] = "/ticketing/index.php/ticketing/info";
$config['first_url'] = "/ticketing/index.php/ticketing/info?search=$search";
}else{
$this->db->where('is_valid','1');
$config['total_rows'] = $this->db->count_all_results('db_ticketing.tr_ticket');
$config['base_url'] = "/ticketing/index.php/ticketing/info";
}
$limit = 10;
$config['per_page'] = $limit;
$config['num_links'] = $limit;
$config['full_tag_open'] = '<div><ul class="pagination pagination-centered">';
$config['full_tag_close'] = '</ul></div>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
$config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";
$config['first_link'] = 'First';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['ticket_list'] = $this->ticketing_mdl->get_all_ticket($limit,$page, $offset);
$this->load->view('ticketing/header');
$this->load->view('ticketing/left_menu');
$this->load->view('ticketing/info',$data);
}
答案 0 :(得分:0)
如果我是对的,请告诉我。
我认为您可以通过定义路线来控制它。
设置 $ config [&#39; base_url&#39;] 的分页库,如example/index.php/search
,并定义路由(application / config / routes.php)
$route['search'] = "example/info";
$route['search/(:num)'] = "example/info/$1";
评论此 $ config [&#39; first_url&#39;] =&#34; /ticketing/index.php/ticketing/info?search = $ search&#34;;
并且不要忘记设置html表单操作=&#34; echo site_url(&#39; search&#39;);&#34;方法=&#34;获得&#34;
我希望这会给你一些帮助。