just insert this function in your controller, and the other function call it:
/**
* set paging for easy use :)
* @access private
* @param string $url
* @param int $total
* @param int $perpage
* @param int $numlink
* @return void
*/
function setPaging($url='', $total=0, $perpage=20, $numlink=3){
if(!is_numeric($total)){
$total=0;
}
if(!is_numeric($perpage)){
$perpage=20;
}
if(!is_numeric($numlink)){
$numlink=3;
}
$this->load->library('pagination');
$segment=explode('/',$url);