Welcome Guest, Not a member yet? Register   Sign In
Pagination Links Not Changing
#1

[eluser]Kemik[/eluser]
Hello,

I have a pagination on my page listing users of my site. When I click "2" for the 10 to 20 users on my pagination links it changes to display the correct users, but the menu continues with "1" in bold.

Controller
Code:
function all()
    {
        // load pagination class
        $this->load->library('pagination');
        $config['base_url'] = base_url().'admin/users/all/';
        $config['total_rows'] = $this->db->count_all('users');
        $config['per_page'] = '10';
        $config['full_tag_open'] = '<p>';
        $config['full_tag_close'] = '</p>';
        
        $this->pagination->initialize($config);
                
        //load the model and get results
        $this->load->model('admin/user_model');
        $data['results'] = $this->user_model->get_users($config['per_page'],$this->uri->segment(4));
                
        // load the HTML Table Class
        $this->load->library('table');
        $this->table->set_heading('User ID', 'Username', 'Email', 'Action');
        
        $data['header'] = '[Admin] Manage Users';
        $data['page'] = 'admin/users';
        $this->load->view('container', $data);

    }

Model
Code:
function get_users($num, $offset)
    {
        /*echo 'Num: ';
        echo $num;
        echo 'Off: ';
        echo $offset;
        exit();*/
        
        $this->db->select('user_id, user_name, email');
        $query = $this->db->get('users', $num, $offset);
        return $query;
    }

View
Code:
<h1>Admin :: Manage Users</h1>

<p>
&lt;?php echo $this->table->generate($results); ?&gt;
&lt;?php echo $this->pagination->create_links(); ?&gt;
</p>

Thanks for your help.

edit: Fixed. Needed to add $config['uri_segment'] = 4;
#2

[eluser]praveens[/eluser]
hi here is the example you do like this u wil get solution

controllers

Code:
function all() {
    
        $arr_data['categorynames']        =    $this->consultantmodel->get_categories();
        $arr_data['statenames']            =    $this->consultantmodel->get_states();
        
        
        $per_page = 10;
        $offset = $this->uri->segment(3) ? (int) $this->uri->segment(3) : 0 ;
        $arr_data['resultset1']            =    $this->consultantmodel->getHome();
        //$this->db->limit($per_page);
        //$this->db->offset($offset);        
        $arr_data['resultset']            =    $this->consultantmodel->getHome1($per_page,$offset);
        $config['base_url']             =   site_url().'/consultants/index';
        $config['total_rows']             =   $arr_data['resultset1']->num_rows();
        $config['per_page']             =   $per_page;
        $config['uri_segment']            =   3;
        $config['first_link']             =  'First';
        $config['last_link']             =  'Last';
        $this->pagination->initialize($config);
        
        $this->load->view('consultants/consulthome',$arr_data);
    }

model

Code:
function getHome() {
    
        $query = $this->db->query("select * from consultants where status=1 order by created_on desc ");
        return $query;
    }
    
    function getHome1($limit,$offset) {
        $this->db->limit($limit);
        $this->db->offset($offset);
        $this->db->orderby('created_on','desc');
        $this->db->where('status',1);
        return $this->db->get('consultants');
        //$query = $this->db->query("select * from consultants where status=1 order by created_on desc ");
        return $query;
    }

view

Code:
<tr>
        <td align="right" class="text-blue2">&nbsp;<span class="text-orange">&lt;?=$this->pagination->create_links(); ?&gt;</span></td>
              </tr>




Theme © iAndrew 2016 - Forum software by © MyBB