You should try the jQuery Pagination plugins : http://tympanus.net/codrops/2009/11/17/jpaginate-a-fancy-jquery-pagination-plugin/
In my implementation, I used both jQuery Pagination and CI Pagination class. I’ve got 2 methods in my controller to do so. The code should be something like below:
/* Your controller */
public function page()
{
$this->load->library(‘pagination’);
$data[‘rows’] = $this->db->limit($this->pagination->per_page, $this->uri->uri_segment(3, 0))
->get(‘dbtable’)
->result_array();
if (count($data[‘rows’])) {
$data[‘jpaginate’] = “<div id=‘paginate-me’></div>”;
$data[‘cipaginate’] = $this->pagination->create_links();
}
$this->load->view(‘table’, $data);
}
public function page_view()
{
$data[‘rows’] = $this->db->limit($this->pagination->per_page, $this->uri->uri_segment(3, 0))
->get(‘dbtable’)->result_array();
$this->load->view(‘table’, $data);
}
/** Your view **/
<?php
if (! empty($jpaginate)) echo $jpaginate));
echo “<div id=‘table’>”;
if (! empty($cipagination)) echo “<noscript>”.$cipagination.”</noscript>”;
echo “<table>”;
echo “<thead>”;
/** Your header goes here **/
echo “</thead><tbody>”;
foreach ($rows as $r) {
echo “<tr>”;
/** Your fields goes here **/
echo “</tr>”;
}
echo “</tbody></table>”;
echo “</div>”;
} ?>
[removed]
$(”#jpaginate-me”).paginate(
{
count: <?php echo $this->pagination->num_pages ; ?>,
start: <?php echo $this->pagination->cur_page; ?>,
display: <?php echo $this->pagination->num_links * 2 + 1; ?>,
onChange: function(page){
$.post(”<?php echo site_url($this->base_url.‘page_view’); ?>” + ‘/’ + (page - 1) * <?php echo $this->pagination->per_page; ?>,
function(response){
$(”#table”).html(response);
}
);
},
}
);
[removed]
To sum up, you create 2 methods, one generate full HTML data and javascript contents and the second only generate the table you want to appears during pagination click.
Then embbed the CI pagination library into <noscript> tags, to display it along the table.
Then finish with jQuery Paginate plugin. That’s all.