[eluser]Bainzy[/eluser]
Hi guys,
Being trying to add pagination into my forum script however i am running into some problems.
What i currently have is categories, and when you click on a category it sorts the database again depending on the category selected, this works via the uri->segment(3) method.
here is a example of the code i use, here is my topics model :
Code:
function getTopics($category)
{
$data = array();
if ($category)
{
$this->db->select('*');
$this->db->join('category', 'category.CategoryID = topics.CategoryID');
$this->db->join('users', 'users.Username = topics.CreatedBy');
$this->db->order_by('topics.TopicID', 'desc');
$options = array('topics.CategoryID'=>$category, 'topics.Active'=>'1');
$q = $this->db->get_where('topics', $options);
}
else
{
$this->db->select('*');
$this->db->join('category', 'category.CategoryID = topics.CategoryID');
$this->db->join('users', 'users.Username = topics.CreatedBy');
$options = array('topics.Active'=>'1');
$this->db->order_by('topics.TopicID', 'desc');
$q = $this->db->get_where('topics', $options);
}
if($q->num_rows() >0)
{
foreach ($q->result_array() as $row)
{
$data[] = $row;
}
}
$q->free_result();
return $data;
} // End of getTopics
And here is my controller code :
Code:
function topics()
{
$data['category'] = $this->MCats->getCurrentCat($this->uri->segment(3));
$data['topics'] = $this->MTopics->getTopics($this->uri->segment(3));
$this->load->view('forums', $data);
}
Now how would i go about adding pagination into this ? every time i try it does not work or does not work how it should
Any help is appreciated here
Regards
Chris