Welcome Guest, Not a member yet? Register   Sign In
pagination help
#21

[eluser]dadamssg[/eluser]
i think something is wrong with my $config. No clue what though

Code:
$this->load->library('pagination');
        $config['base_url'] = 'http://mysite.com/mains/index/';
        $config['total_rows'] = $this->db->count_all('test');
        $config['per_page'] = '5';
        
        $this->pagination->initialize($config);
#22

[eluser]dadamssg[/eluser]
OH...i thought the links would match with whats in the 3rd segment of the uri. then i guess its working now then
#23

[eluser]dadamssg[/eluser]
THANK YOU SO FREAKIN MUCH
#24

[eluser]dadamssg[/eluser]
question....if youre gonna use multiple functions in model, do you have to call it every time or can you just call it once?
#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




Theme © iAndrew 2016 - Forum software by © MyBB