CodeIgniter Forums
pagination problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: pagination problem (/showthread.php?tid=16682)

Pages: 1 2


pagination problem - El Forum - 03-13-2009

[eluser]genny[/eluser]
This report shows a 1-to-many relationship with product description at the top, followed by multiple comments down the page. Pagination looks like it's working on page 1, but when you go to page 2 there's nothing there - no product description and no comments - and you can't go back to page 1, and keep getting the same blank page 2 over and over. I tried putting 'pagination->create_links()' in both the view and the controller and neither works. Here is the code:
Code:
// Load Pagination    
               $items_per_page=4;                        
                $this->load->library('pagination');
                $config['base_url'] = base_url ().'company/display/'.$keyword;
                $config['total_rows'] = $this->db->count_all_results('product_comment');
                $config['per_page'] = $items_per_page;              
                $config['uri_segment'] = 4;
                $this->pagination->initialize($config);
          
     // Product Output
                $product['page']    = $this->pagination->create_links();
                $product['keyword']    = $keyword;
              
                // Load View
                $info['content']    = $this->load->view('default/product_display',$product,true);
            
?>



pagination problem - El Forum - 04-19-2009

[eluser]aataqwa[/eluser]
I'm used pagination like this:

Code:
public function index(){
        $this->load->library(array('form_validation','pagination'));
        
        $this->form_validation->set_rules('search','','');
        
        $config['base_url'] = base_url().'index.php/memsearch/index/';
        if($this->form_validation->run()){
            $this->session->set_userdata('keywords',$this->input->post('search'));
        }else{
            if(!$this->uri->segment(3))$this->session->unset_userdata('keywords');
        }
        $keywords = $this->session->userdata('keywords');
        $data['from_rows'] = $this->uri->segment(3); //untuk no urut paging
        $config['total_rows'] = $this->MSearch->countMember($keywords);
        $config['per_page'] = 1;
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);
        
        $data['results'] = $this->MSearch->searchMember($keywords,$config['per_page'],$data['from_rows']);
        $data['page_title'] = 'Member Search';
        
        $this->load->view('search/member_search',$data);
    }



pagination problem - El Forum - 04-21-2009

[eluser]Unknown[/eluser]
hey my friends i have a problem with pagination, how i can apply a css to pagination.
thanks


i really need that!!!!


pagination problem - El Forum - 04-21-2009

[eluser]xwero[/eluser]
use the template settings to set an id or classes for the generated html elements.


pagination problem - El Forum - 04-21-2009

[eluser]simshaun[/eluser]
genny, I'm not sure if you figured out your problem yet, but its possible you may be thinking the number in the URL should be the page number, when in fact its an offset.


pagination problem - El Forum - 04-22-2009

[eluser]genny[/eluser]
Could you explain what you mean by offset? What is it an offset to?

Thanks,
Genny


pagination problem - El Forum - 04-22-2009

[eluser]simshaun[/eluser]
Offset being the same value you would use in an actual SQL query.

Say you want to retrieve the first thirty rows of a table, well the offset is going to be 0.
SQL: LIMIT 0, 30

Then you want to retrieve the next thirty rows (page 2), then the offset is going to be 30.
SQL: LIMIT 30, 30


pagination problem - El Forum - 04-22-2009

[eluser]genny[/eluser]
So you're saying that the offset is how many rows you want to display on each page, as opposed to how many pages. That makes sense. I'm a bit rusty as I have not looked at this for quite a while. After trying all kinds of changes and being unable to resolve the problem, I gave it back to the original programmer who finally got it fixed by applying some black magic. Thanks to all for your help. --g


pagination problem - El Forum - 04-22-2009

[eluser]simshaun[/eluser]
no. how many rows you want to display per page is exactly that. offset is which row to start pulling records from.


pagination problem - El Forum - 04-23-2009

[eluser]genny[/eluser]
I see, so maybe I didn't understand what you meant by "the number in the url". I thought you were referring to $config['uri_segment'] = 3;
There I was specifying 3 rows per page. I don't see anywhwere to specify the offset, which I assume would start at 0 then get bumped up by 3 each time a new page is retrieved.