[eluser]Ludatha[/eluser]
Hey, I'm have been creating a comments system for my site today and I cannot get the pagination links to appear. I have managed to get the links to appear in the past but not now. The only thing different is that I am coding this as a library not a controller.
This is my library function:
Code:
// Library = Ludatha
function getComments($type, $id, $url, $colspan = 1, $offset = 0, $perPage = 10){
$CI =& get_instance();
$offset2 = $offset + $perPage;
$query = $CI->db->query("SELECT * FROM comments WHERE forId = '$id' AND type = '$type' LIMIT $offset, $offset2");
$comments = '';
if ($query->num_rows() > 0)
{
$config['base_url'] = $this->baselink . $url;
$config['total_rows'] = $query->num_rows();
$config['per_page'] = $perPage;
$config['uri_segment'] = 4;
foreach ($query->result() as $row){
$comments .= '<tr><td colspan="'.$colspan.'">comments</td></tr>';
}
$CI->pagination->initialize($config);
$comments .= '<tr><th colspan="'.$colspan.'">'.$CI->pagination->create_links().'</th></tr>';
}else{
$comments .= '<tr><td colspan="'.$colspan.'">There are no comments yet.</td></tr>';
}
return $comments;
}
Code:
$this->ludatha->getComments(1, 1, $this->ludatha->baselink . "profile/view/" . $username, 3, $comOffset)
The data appears, and when I add /10 to the end of the URL the next 10 results are displayed. The only thing wrong is the fact that the create_links() function will not show anything at all.
My errors are generally ones that I cannot see but are pretty simple, so I am sorry if this is a simple thing to fix
Can anyone shed any light?
Thanks
- Adam