[eluser]Unknown[/eluser]
I have a category function that display results from a mysql database by the column called category. All seems to be working well now, but when I switch to the second page the current page number remains at 1, when I am really on page 2. How can I fix this?
The category function:
Code:
function category($category = '') {
if($category == '') {
redirect('inspiration/index');
} else {
$config['base_url'] = "http://".$_SERVER['SERVER_NAME']."/index.php/inspiration/category/".$category;
$config['cur_tag_open'] = ' <b>[';
$config['cur_tag_close'] = ']</b>';
$config['next_link'] = 'Next >';
$config['prev_link'] = '< Prev';
$config['last_link'] = 'Last »';
$config['first_link'] = '« First';
$config['total_rows'] = $this->db->get_where('inspiration', array('category' => $category))->num_rows();
$config['per_page'] = 8;
$config['num_links'] = 2;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
if($config['total_rows'] < 1) {
$data['empty'] = '<p class="error">No designs are listed in the category "'.$category.'"</p>';
}
$data['title'] = $this->title;
$data['heading'] = 'Web Design Inspiration';
$data['category'] = $this->inspiration_model->list_categories();
$data['color'] = $this->list_colors();
$data['inspiration'] = $this->db->get_where('inspiration', array('category' => $category), $config['per_page'], $this->uri->segment(4));
$this->load->view('inspiration_view', $data);
}
}
Edit: Sorry, should have posted this in the debugging section.