Welcome Guest, Not a member yet? Register   Sign In
Pagination question
#9

[eluser]artur z[/eluser]
Thanks,
It seems that the offset needs a small push forward (backward actuallly) to work.
The code below works fine:

Code:
function paginate()
        {
            
            /* base url is http://localhost:8888/culinari/ */
            $config['base_url'] = base_url().'test/paginate';
            $config['total_rows'] = $this->db->count_all('receipts');
            $config['per_page'] = '1';
            $config['uri_segment'] = '3';
            /* Sanity check, return only one result per page*/
            $config['num_links'] = '0';

            /* Initialize config */
            $this->pagination->initialize($config);

            /* Correct our offset */
            if($this->uri->segment(3) > '0'):
            $offset=$this->uri->segment(3) -1;
            elseif(!$this->uri->segment(3)):
            $offset=0;
            endif;

            /* Order by id, ASC */
            $this->db->orderby('id', 'asc');
            /* Run query */
            $data['query'] = $this->db->get('receipts', $config['per_page'], $offset);
            /* Take us to our view */
            $this->load->view('test', $data);


        }

    }


Messages In This Thread
Pagination question - by El Forum - 01-28-2008, 12:13 PM
Pagination question - by El Forum - 01-28-2008, 02:34 PM
Pagination question - by El Forum - 01-28-2008, 02:50 PM
Pagination question - by El Forum - 01-28-2008, 03:03 PM
Pagination question - by El Forum - 01-29-2008, 09:41 AM
Pagination question - by El Forum - 01-30-2008, 04:38 AM
Pagination question - by El Forum - 01-30-2008, 03:07 PM
Pagination question - by El Forum - 01-30-2008, 08:37 PM
Pagination question - by El Forum - 01-31-2008, 12:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB