Welcome Guest, Not a member yet? Register   Sign In
pagination doesn't work
#1

Hi guys.
what part is wrong? here is my code. and here is error

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined index: username

Filename: users/index.php

Line Number: 45

controller:
PHP Code:
public function index(){
        
$this->load->library('pagination');
        
$this->load->model('user_model');

        
$config['base_url'] = base_url().'index.php/admin/index.php/user/page';
        
$config['total_rows'] = $this->user_model->get_users_count();
        
$config['per_page'] = 1;
        
$config['uri_segment'] = 4;
        
$page = ($this->uri->segment(4))?$this->uri->segment(4):0;
        
$config['first_link'] = 'First';
        
$config['last_link'] = 'Last';
        
$this->pagination->initialize($config);
        
        
$data['result'] = $this->user_model->get_all($config['per_page'], $page);
        
$data['link'] = $this->pagination->create_links();

        
$this->template->load('users/index', array('users' => $data));
    } 

Model:
PHP Code:
public function get_all($limit,$start){
        return 
$this->db->get('users'$limit$start)->result_array();
    }

    public function 
get_users_count(){
        return 
$this->db->count_all('users');
    } 

view:
PHP Code:
<?php foreach($users as $key => $value):?>
                            <tr>
                                <td><?=$value['username']; ?></td>
                                <td><?=$value['email'];?></td>
                                <td><?=$value['status'];?></td>
                                <td><?=$value['access'];?></td>
                            </tr>
                            <?php endforeach; ?>

                            <?php
                                
echo $pagination;
                            
?>
Reply


Messages In This Thread
pagination doesn't work - by chouwech - 03-21-2015, 11:39 AM
RE: pagination doesn't work - by RobertSF - 03-21-2015, 08:34 PM
RE: pagination doesn't work - by chouwech - 03-22-2015, 01:24 AM
RE: pagination doesn't work - by RobertSF - 03-22-2015, 07:49 AM
RE: pagination doesn't work - by chouwech - 03-22-2015, 10:22 AM
RE: pagination doesn't work - by RobertSF - 03-22-2015, 11:55 AM
RE: pagination doesn't work - by chouwech - 03-22-2015, 01:18 PM
RE: pagination doesn't work - by phoenixcoded - 03-25-2015, 05:43 AM
RE: pagination doesn't work - by RobertSF - 03-25-2015, 07:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB