Welcome Guest, Not a member yet? Register   Sign In
Pagination Bug
#1

[eluser]Roosevelt![/eluser]
Hello,
I am not sure if it is a bug or an error in my code. For some reason when I generate
the pagination links, it generates the links as:

1 2 3 4

Where page 3 is linking to 4.

Code:
$this->load->library('pagination');
                            
$config['base_url'] = site_url("products/{$cat_id}/page/");
$config['total_rows'] = 10;
$config['per_page'] = $RowsPerPage; //using $this->db->count_all('products');
$config['uri_segment'] = 4;

echo $this->pagination->initialize($config);

So in a way, page three doesn't even exist.
#2

[eluser]Référencement Google[/eluser]
I think you inverted the total rows and per page, this should be:

Code:
$config['total_rows'] = $RowsPerPage; //using $this->db->count_all('products');
$config['per_page'] = 10;
#3

[eluser]Roosevelt![/eluser]
I typed the wrong code it is actually like this:

$config['base_url'] = site_url('products/browse/$category/page');
$config['total_rows'] = $TotalRows;
$config['per_page'] = $RowsPerPage;
$config['uri_segment'] = 5;

For testing purposes I set total_rows to 200, and per_page to 10, and removed the uri_segment config.

From what I figured out is that the page_num variable actually holds the offset value. But what I was doing is reassinging the offset again using the following math:

$offset = $pagenum * $rowsperpage.

So it was generating weird results :p.




Theme © iAndrew 2016 - Forum software by © MyBB