使用Codeigniter分页搜索

时间:2014-07-26 19:03:14

标签: codeigniter

当我转到第二或第三个..etc页面时,使用此代码的所有内容都是完美的 我可以正常浏览它们,当我想浏览第一页时我的第一页问题,

它给了我这个网址(http://www.example.com/almanara-shipping/index.php/dashboard/search/)??

它应该给我这个网址(http://www.example.com/almanara-shipping/index.php/dashboard/search?keyword=ali

公共功能搜索($ page_start = 0){

    $this->load->model('Customers');
    $keyword = $this->input->get('keyword');

    $data['customers'] = $this->Customers->search($keyword ,2,$page_start);
    $this->load->library('pagination');
    $config['suffix'] = '?keyword='.$keyword;
    $config['base_url'] = site_url()."/dashboard/search/";
    $config['total_rows'] = $this->Customers->search_count($keyword);
    $config['per_page'] = 2;
    $config['full_tag_open'] = "<ul class='pagination'>";
    $config['full_tag_close'] ="</ul>";
    $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>";


    $this->pagination->initialize($config);
    $data['pages'] = $this->pagination->create_links();
    $this->load->view('customers',$data);
    $this->load->view('templates/footer');

}

1 个答案:

答案 0 :(得分:0)

我使用下面的代码解决了这个问题

$config['first_url'] = $config['base_url'].'?'.http_build_query($_GET);