0
votes

Everything with this code is perfect, when I go to second or third ..etc pages I can browse them normally, my issue with first page when I want to browse first page ,

it gives me this url (http://www.example.com/almanara-shipping/index.php/dashboard/search/)??

it should give me this url (http://www.example.com/almanara-shipping/index.php/dashboard/search?keyword=ali)

public function search($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
So your issue is that the query string isn't available on the first page? - Rwd
What do you mean? I didn't get - allaghi
everything with pagination is okay, except the link of first page first page example.com/index.php/dashboard/search example.com/index.php/dashboard/search2?keyword=ali - allaghi
So, it's because it's missing ?keyword=ali? - Rwd
yes exactly so I added this line $config['first_url'] = config['base_url'].'?'.http_build_query($_GET); - allaghi

1 Answers

0
votes

I solved the issue by using this code below

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