CI pagination not working
I want to use pagination in CI but when i click on links i get the error invalid argument supplied for for each. I get a category id from link by get method. The first link is working but when I click it again, it doesn't work. Here is my link:
topic_title ?>
i don't know why its not working. please guide me here is my controller
public function categories()
{
$cat_id = $this->input->get('cate',TRUE);
$data['cat_id'] = $cat_id;
$data['categories_list'] = $this->mod_forum->categories_list();
$count = $this->mod_forum->record_count_sort($data);
$data['categories_pic'] = $this->mod_forum->categories_pic($data);
$config = array();
$config["base_url"] = base_url() . "index.php/forum/categories?cat=$cat_id";
$config["total_rows"] = $count->num_rows();
$config["per_page"] = 5;
$config["uri_segment"] = 3;
$config["cat_id"] = $cat_id;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["topics_sort"] = $this->mod_forum->fetch_sort_category($config["per_page"], $page,$config["cat_id"]);
$data["sort"] = $this->pagination->create_links();
$this->load->view('header');
$this->load->view('navi');
$this->load->view('forum/category_content',$data);
$this->load->view('footer');
}
this is my model
public function record_count_sort($data) {
return $this->db->get_where('topics',array('cat_id'=>$data['cat_id']));
}
public function fetch_sort_category($limit, $start,$cat_id) {
$this->db->limit($limit, $start);
$query = $this->db->get_where('topics',array('cat_id'=>$cat_id));
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
}
return $data;
}
return false;
}
this is my view