pagination help

#25
[eluser]maria clara[/eluser]
hi,

i also encountered that one.. try this script.
Code:
$this->db->order_by($sidx,$sord);
        $this->db->limit($limit, $start);
        $query = $this->db->get('ar_so');
        $count = $this->db->count_all_results();
        
        // calculate the total pages for the query - code added by cess
        if( $count > 0 && $limit > 0) {
              $total_pages = ceil($count/$limit);
        } else {
              $total_pages = 0;
        }
        
        // if for some reasons the requested page is greater than the total
        // set the requested page to total page - code added by cess
        if ($page > $total_pages) $page=$total_pages;
        
        // calculate the starting position of the rows
        $start = $limit * $page - $limit; // do not put $limit*($page - 1)
        
        // if for some reasons start position is negative set it to 0
        // typical case is that the user type 0 for the requested page
        if($start <0) $start = 0;
        
        $this->db->flush_cache();

        $data['db'] = $query;        
        $data['page'] = $page;
        $data['num'] = $total_pages;
        $data['totalPages']=$count;
        return $data;

hope it would help you..

regards,
maria


Messages In This Thread
pagination help - by El Forum - 01-09-2010, 07:34 PM
pagination help - by El Forum - 01-09-2010, 07:54 PM
pagination help - by El Forum - 01-09-2010, 08:09 PM
pagination help - by El Forum - 01-09-2010, 08:16 PM
pagination help - by El Forum - 01-09-2010, 08:27 PM
pagination help - by El Forum - 01-09-2010, 08:44 PM
pagination help - by El Forum - 01-09-2010, 08:47 PM
pagination help - by El Forum - 01-09-2010, 08:55 PM
pagination help - by El Forum - 01-09-2010, 09:05 PM
pagination help - by El Forum - 01-09-2010, 09:08 PM
pagination help - by El Forum - 01-09-2010, 09:18 PM
pagination help - by El Forum - 01-09-2010, 09:21 PM
pagination help - by El Forum - 01-09-2010, 09:31 PM
pagination help - by El Forum - 01-09-2010, 09:33 PM
pagination help - by El Forum - 01-09-2010, 09:34 PM
pagination help - by El Forum - 01-09-2010, 09:36 PM
pagination help - by El Forum - 01-09-2010, 09:40 PM
pagination help - by El Forum - 01-09-2010, 09:49 PM
pagination help - by El Forum - 01-09-2010, 10:01 PM
pagination help - by El Forum - 01-09-2010, 10:02 PM
pagination help - by El Forum - 01-09-2010, 10:05 PM
pagination help - by El Forum - 01-09-2010, 10:06 PM
pagination help - by El Forum - 01-09-2010, 10:10 PM
pagination help - by El Forum - 01-09-2010, 10:19 PM
pagination help - by El Forum - 01-10-2010, 07:27 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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