Welcome Guest, Not a member yet? Register   Sign In
Pagination does not behave as I expect

I am trying out CodeIgniter and my first experiment is just a Guestbook, but the Pagination Library does some strange things. My code is this:

function page($number=1)
        $config['base_url'] = site_url("guestbook/page");
        $config['total_rows'] = $this->entries->count();
        $per_page = 3;
        $config['per_page'] = $per_page;
        $data['title'] = "Gästebuch";
        $data['entries'] = $this->entries->get_some_after($per_page,$number);
        $data['pagination'] = $this->pagination->create_links();
        $this->load->view('guestbook', $data);
get_some_after is SELECT LIMIT OFFSET.
I would have expected, that I should have written
$data['entries'] = $this->entries->get_some_after($per_page,$per_page*$number-$per_page);
but I get links in my Pagination like .../page, .../page/3, .../page/6 etc.
I'd rather have /1, /2, /3 etc.

Is there something wrong with my code, or is this the way it is meant to be?

[eluser]Phil Sturgeon[/eluser]
Yes indeed, uses offset and limit instead of page numbers. You can try the replacement library on the wiki.

Yes, it uses offsets instead of pages, but no need to use a different library, just do this.

function page($number=1){
    $offset = ($number > 1) ? $number : 0;
    // do stuff

Theme © iAndrew 2016 - Forum software by © MyBB