[eluser]epseix[/eluser]
Right, using pagination for the first time and CANNOT get it to work beyond the first page (404 error). It all seems to revolve around the $offset variable as if I change the offset's variable to an integer (such as 15), it displays the results on the first page from row 15 onwards - but the $this->uri->segment(2) variable is just not working. It all displays correctly, but second page won't load (as I said, 404 error).
Controller:
Code:
<?php
class Brands extends CI_Controller
{
public function index()
{
$this->load->library('pagination');
$config['base_url'] = base_url() . '/brands/';
$config['total_rows'] = $this->db->count_all('seixweb');
$config['per_page'] = 15;
$limit = $config['per_page'];
$offset = $this->uri->segment(2);
$this->pagination->initialize($config);
$this->load->model('Default_model');
... Etc.
}
}
Model:
Code:
<?php
class Default_model extends CI_Model
{
function get_list($limit, $offset)
{
$query = $this->db->get('tbl', $limit, $offset);
return $query->result_array();
}
}
URL (first page):
Code:
http://www.mydomain.com/brands
URL (second page):
Code:
http://www.mydomain.com/brands/15
What am I doing wrong?