Welcome Guest, Not a member yet? Register   Sign In
Pagination 404 on Page 2
#1

[eluser]gscharlemann[/eluser]
I'm getting a 404 Page Not Found error when attempting to use pagination. I think it's in the way that I'm sending the base_url to Pagination, but I can't seem to figure out the correct way to specify it. The pagination class is also showing all results from the DB, it's not stopping the results after the "per_page" specification. Here's some code:

Controller:
file located in application/controller/contact/contact.php
Code:
class Contact extends Controller {
    function Contact() {
        parent::Controller();
        $this->load->library('pagination');
        $this->load->model('Contact_model');
    }
  
    function index() {
        $this->_display_contacts();
    }

    function _display_contacts() {
        $query = $this->Contact_model->get_contacts();
        $contact_array = $query->result_array();
        $data['contact_array'] = $contact_array;

        //pagination stuff
        $config['base_url'] = site_url("contact/contact/");
        $config['total_rows'] = $query->num_rows();
        $config['per_page'] = 2;
        $this->pagination->initialize($config);
        $pagination = $this->pagination->create_links();
        $data['pagination'] = $pagination;
        $this->load->view('contact/display_contacts', $data);
    }
}

View:
file located in: application/views/contact/display_contact.php
Code:
<table>
&lt;?php foreach($contact_array as $contact):?&gt;
    <tr>
        <td>&lt;?php echo($contact['first_name'])?&gt;</td>
    </tr>
&lt;?php endforeach;?&gt;
</table>
&lt;?php echo($pagination)?&gt;

Page 1 displays all of the results from the database. Page 2 link gets a 404 error (http://www.mysite.com/index.php/contact/contact.html/2) - the config file is setup to put '.html' at the end of the url. My questions are as follows:
1. what URL should I specify as base_url. I've also tried
Code:
site_url("contact/display_contacts");
- but there is no display_contacts() method in the contact controller.
2. what am I doing wrong in the view? how do I get the pagination to work with $contact_array?

Thanks in advance for reading this and providing feedback!


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



Theme © iAndrew 2016 - Forum software by © MyBB