little Pagination/Uri offset problem

Hi everybody,
I'm pretty new to CI, I mainly followed videos from BinaryCake and Nettus/Tuts+.
I just finished the lastest nettuts plus tut on pagination in CI, everything works perfectly except that little uri problem.
Basically what happens is that:
-when I'm on page 1, the url is http://localhost:8888/mamp/CodeIgniter/pagination/index.php/blogs/index/
-on page 2 http://localhost:8888/mamp/CodeIgniter/pagination/index.php/blogs/index/1
-page 3 http://localhost:8888/mamp/CodeIgniter/pagination/index.php/blogs/index/2, etc
where it should be (I think) http://localhost:8888/mamp/CodeIgniter/pagination/index.php/blogs/index/3 on page 3.

Here is the code snippet in question:
function index()
            $config['base_url'] = base_url().'/index.php/blogs/index/';
            $config['total_rows'] =  $this->db->count_all('blogs');
            $config['per_page'] =  1;
            $data['pagination_links'] = $this->pagination->create_links();
            $this->db->order_by('blog_id', 'DESC');
            $data['blog_query'] = $this->db->get('blogs', $config['per_page'], $this->uri->segment(3));
            $this->load->view('blog_index', $data);

I tried to change $config['per_page'] to 2 and I got a similar problem:
$config['per_page'] =  2;
on page 2 the offset was indeed 2 (http://localhost:8888/mamp/CodeIgniter/pagination/index.php/blogs/index/2), however on page 3 the offset became 4 (http://localhost:8888/mamp/CodeIgniter/pagination/index.php/blogs/index/4).

Now there is clearly something wrong with my code...
Can somebody explain me what's the problem please?

[eluser]GSV Sleeper Service[/eluser]
There's nothing wrong with your code, the documentation is incorrect. the value in the URI is actually the offset, not the page number as it states.

Oh ok thanks.
But in that case how would I be able to display the correct page number in the URI please?

[eluser]GSV Sleeper Service[/eluser]
write your own pagination library! the CI one is quite easy to modify

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.