1
$config['suffix'] = '?'.http_build_query($_GET, '', "&");

I am using codeigniter's pagination class for a function in the controller that uses a get post. Everything works fine. The links are produced and I can go to every page etc. But when I click first it take me to the url: http://www.example.com/controller/function/ and ignores the suffix I asked it to append at the end of the function. For example, when 2 is my current page and I hit 1 it does not work: 1,2,4,5,6,... When it automatically takes me to the first link, i.e. page 1 it all works fine though.

Edit:

$this->load->library('pagination');
        $config['suffix'] = '?'.http_build_query($_GET, '', "&");
        $config['base_url'] = 'http://www.example.com/controller/function';
        $config['total_rows'] = count($results);
        $config['per_page'] = 15;
        $config['num_links'] = 3;
$this->pagination->initialize($config);

So, I am using the get to build the query that the user previously submitted (it's a search function - so the get is necessary) and not to get the number of the page! Hope that this is clearer.

dreamer_999
  • 1,465
  • 3
  • 17
  • 22

1 Answers1

0

-make sure you have your

$config['base_url'] = 'http://example.com/index.php/controller/pagination_function/'

set to the correct place.

-Why are you using $_GET[''] ? you should use codeigniter's built in

$this->uri->segment(n)

ex.

http://website.com/mycontroller/myfunction/myname/mybirthday
$name = $this->uri->segment(3);
$birthday = $this->uri->segment(4);

Also you should be aware that the uri space after the function in the url is for parameters to the said function, if you are arbitrarily adding uri's after that and not using them as parameters you should avoid such implementation.