Pagination 404 on Page 2

#6
[eluser]gscharlemann[/eluser]
Thanks for the help. I've successfully implemented pagination. It's probably not as "clean" as it could be, but I modified the controller method to the following:
Code:
// needed to define what page to view.  $index is set to default to
// zero in the index function. i.e.: function index($index = 0) {...
function _display_contacts($index) {
    //because the url looks like so when a new page is requested:
    // mysite.com/index.php/contact/contact/index/#
    // i needed to get the 4th uri segment
    if($this->uri->segment(4) != NULL ) {
        $index = $this->uri->segment(4);
    }
    $per_page = 5;
    
    // i changed the function in the model to accept a limit and offset
    $query = $this->Contact_model->get_contacts($per_page, $index);
    $data['results'] = $query->result_array();

    // set the config file info for pagination.  the library was loaded in the constructor
    $config['base_url'] = site_url("contact/contact/index/");
    $config['total_rows'] = $this->Contact_model->get_total_contact_count();
    $config['per_page'] = $per_page;
    
    $this->pagination->initiatlize($config);
    $pagination = $this->pagintation->create_links();
    $data['pagination'] = $pagination;
    $this->load->view('contact/display_contacts', $data);
}

The View (display_contacts.php):
Code:
<table>
&lt;?php foreach($results as $contact):?&gt;
    <tr>
        <td>&lt;?php echo($contact['name'])?&gt;</td>
    </tr>
&lt;?php endforeach;?&gt;
</table>
&lt;?php echo($pagination)?&gt;


the problem I experience now is when I go to page 2, the correct results are returned, but the pagination links created at the bottom, do not reflect being on page 2. It still says I'm on page 1. Any thoughts as to why? How do I tell the links, which page we are on?


Messages In This Thread
Pagination 404 on Page 2 - by El Forum - 03-28-2009, 06:51 AM
Pagination 404 on Page 2 - by El Forum - 03-28-2009, 07:07 AM
Pagination 404 on Page 2 - by El Forum - 03-28-2009, 07:17 AM
Pagination 404 on Page 2 - by El Forum - 03-28-2009, 08:15 AM
Pagination 404 on Page 2 - by El Forum - 03-28-2009, 10:11 AM
Pagination 404 on Page 2 - by El Forum - 03-28-2009, 11:36 AM
Pagination 404 on Page 2 - by El Forum - 03-28-2009, 12:07 PM
Pagination 404 on Page 2 - by El Forum - 06-26-2009, 07:18 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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