Welcome Guest, Not a member yet? Register   Sign In
Another pagination 404 Page not found issue
#1

[eluser]juggernautsei[/eluser]
Before you jump on me. I googled this issue and read everyone of the post on this site and none of them helped me to figure out what I did wrong. All the codes are setup different than mine so I had no close comparison to make that leap.

So here goes:

Controller code
Code:
public function index(){
    
    
    $this->load->library('pagination');
    
    $config['base_url'] = current_url();
    $config['total_rows'] = $this->db->get('account')->num_rows();
    $config['per_page'] = 20;
    $config['use_page_numbers'] = TRUE;
    $config['uri_segment'] = 3;
    //$config['num_links'] = 10;
    
    $this->pagination->initialize($config);
        
    $this->load->library('table');
    $children = array();
    $this->load->model(array('Account'));
    
    $account = $this->Account->get($config['per_page'], $config['uri_segment']);      //retrieves all the records in the database
      foreach ($account as $c){
       $account = new Account();
       $account->load($account->id);
       $children[] = array(
        $c->id,
           $c->familyName,
        $c->addr1,
        $c->city,
        $c->state,
        $c->zip,
        $c->phone1,
        $c->email,
        $c->parent_only,
       );
      }
  
    $this->load->view('main_view');
    $this->load->view('body_content_ma', array(
     'body_content_ma' => $children
      ));
    
   }

Model Code:
Code:
class MY_Model extends CI_Model {

    const DB_TABLE = 'abstract';
    const DB_TABLE_PK = 'abstract';

    public function get($limit = 0, $offset = 0) {
        if ($limit) {
            $query = $this->db->get($this::DB_TABLE, $limit, $offset);
        }
        else {
            $query = $this->db->get($this::DB_TABLE);
        }
        $ret_val = array();
        $class = get_class($this);
        foreach ($query->result() as $row) {
            $model = new $class;
            $model->populate($row);
            $ret_val[$row->{$this::DB_TABLE_PK}] = $model;
        }
        return $ret_val;
    }

View Code:
Code:
<?php
           $this->table->set_heading('ID', 'Family Name', 'Address', 'City', 'State', 'Zip', 'Phone', 'Email', 'Parent only Pickup');
           echo $this->table->generate($body_content_ma )
              . $this->pagination->create_links();
          
          ?>

The pagenation is at the bottom of my page but when I click them I get page not found.
Not sure where to go from here.
#2

[eluser]CroNiX[/eluser]
What do the pagination links look like and what SHOULD they look like? The problem most likely is you are using the index method of your class for pagination, but "index" isn't present in the url, which it normally isn't because it's a special case (default method).
#3

[eluser]juggernautsei[/eluser]
Thanks for the reply.

The link that is generated is http://mywebsite/sitefolder/index.php/manageaccounts/1
#4

[eluser]juggernautsei[/eluser]
You were right the base url was the problem.

I changed it from

$config['base_url'] = current_url();

to

$config['base_url'] = '../index';

I was missing the index method at the end of the URL.

This also solved my issue on how to make it dynamic.







Theme © iAndrew 2016 - Forum software by © MyBB