• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination in library file return blank result

I'm working on a library for something I want to paginiate the results of a SQL query.

I've loaded he pagination library in the constructor of the library.

//and other needed variables

$this->controller = $this->CI->uri->segment(1);
// Set the base URL
$this->base_url = $this->CI->config->site_url().'/'.$this->CI->uri->segment(1).$this->CI->uri->slash_segment(2, 'both');

//assume total_rows also has value say 10 and query is running OK.

I just need a function to get the pagination links that I can send to the controller as an array element like

$query_res['paging_links']=paginate(5); //5 is per page results

The paginate function that return me nothing is:

function paginate($page_size){
        //LIMIT ".$offset.",".$perpage);
         $config['uri_segment'] = 4; //$this->CI->URI->total_segments();
         $config['base_url'] = $this->base_url;
         $config['total_rows'] = $this->total_rows;
         $config['per_page'] = $page_size;
         $config['num_links'] = 5;
         $config['full_tag_open'] = '<div id="pagination">';
         $config['full_tag_close'] = '</div>';
         $config['first_link'] = '<< Start';
         $config['last_link'] = 'End >>';
         $config['next_link'] = 'Next >';
         $config['prev_link'] = '< Prev';
        echo "<br><br>Paging links in paginate has: ".$paging_links;
        return $paging_links;
    }//function paginate close

Above paginate function used to work ok in a controller, Whats wrong with the above code, please help...

$this->CI ?
Probably you need to use
$CI =& get_instance();
// ............

Also, It is recommended to enable display_errors on development to find out the errors faster... you can simple ini_set('display_errors', 'On');

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.