[eluser]nagata[/eluser]
ok guise so I have a forum and I need to implement pagination SOMEHOW
I have been trying to make the native CI pagination class to work but failed...
You can see it here
http://zetaworks.myvnc.com/index.php/for...essages/9/
So if someone could help me make it work I would be very happy!
the code's:
Model
Code:
function get_messages($validtopic,$items) {
$threadsql = "SELECT messages.*, users.username FROM messages, users WHERE messages.user_id = users.user_id AND messages.topic_id = '$validtopic' ORDER BY messages.date";
$threadresult = $this->db->query($threadsql);
if ($threadresult->num_rows() > 0) {
return $threadresult->result_array();
}
else {
return FALSE;
}
}
Controller
Code:
function viewmessages()
{
$data['css'] = $this->css;
$data['base'] = $this->base;
$this->load->model('Listings_model');
$mytopic_id = $this->uri->segment(3, 0);
$start_page = $this->uri->segment(4, 0);
// /forum/msg/(:num)
//echo $mytopic_id;
if (($mytopic_id !== NULL) && (is_numeric($mytopic_id))) {
$validtopic = $mytopic_id;
$data['validtopic'] = $validtopic;
$msgname = $this->Listings_model->get_msg_name($validtopic);
$data['msgname'] = $msgname;
//print_r($data['msgname']);
$messagesresult = $this->Listings_model->get_messages($validtopic,$start_page);
$data['reply_count'] = count($messagesresult);
//print_r($messagesresult);
if ($messagesresult != 0) {
$data['messagesresult'] = $messagesresult;
}
else {
echo "BOO HOO";
}
$data['title'] = 'View Messages';
$this->load->view('templates/header_template', $data);
$this->load->view('forum/viewmessages',$data);
$this->load->view('templates/footer_template');
//Load page contents into template
////$this->template->display('viewmessages', $data);
//////
} else {
redirect('/forum/');
return;
}
}
View
Code:
<?php
$topicid= $this->uri->segment(3,0);
$config['base_url'] = "/index.php/forum/viewmessages/$topicid";
$config['total_rows'] = $reply_count;
$config['per_page'] = 10;
$this->pagination->initialize($config);
echo $this->pagination->create_links();
?>
So guise help me