Welcome Guest, Not a member yet? Register   Sign In
Pagination do not correct display page numbers
#1

[eluser]kolxoznik1[/eluser]
My controller function

Code:
function test($start_from = 0)
    {
        $this->load->library('pagination');
        
        $data = array();
        
        $per_page = 3;
        $total = $this->activity_model->count_by();
        
        $config['base_url'] = base_url() . 'test';
        $config['total_rows'] = $total;
        $config['per_page'] = $per_page;
        $config['uri_segment'] = 2;
        $config['num_links'] = 2;
        $config['use_page_numbers'] = TRUE;
        
        $data['follow'] = $this->activity_model->get($per_page, $start_from);
        
       $this->pagination->initialize($config);
        
       $data['pagination'] = $this->pagination->create_links();
        
        $this->load->view('front_end/test' ,$data);
    }

my route :

Code:
$route['test'] = "user_activity/test";
$route['test/(:any)'] = "user_activity/test/$1";

model :

Code:
function get($limit,$start_from)
     {
     $sql = "SELECT * FROM user_follow LIMIT $start_from, $limit";
        
      $query = $this->db->query($sql);
      return $query->result_array();
     }

Problem is that I have pagination 1,2,3,4,5.... and in every page I display 3 items. I want to do that in url it show my page numbers 1,2,3,4,5

When I click second page url show 3
When I click third page url show 6 and so on +3

is it possible, I spend hours for looking advice on internet but nothing as I understand
Code:
$config['use_page_numbers'] = TRUE;
do what I need but in my case it still do not work.

Second question about my model why when I try to put in my sql LIMIT ?, ? and $query = $this->db->query($sql array($limit,$start_from)); I get error ?
#2

[eluser]InsiteFX[/eluser]
This should be 3
Code:
$config['uri_segment'] = 3;

//                             1         2   3
$route['test/(:any)'] = "user_activity/test/$1";




Theme © iAndrew 2016 - Forum software by © MyBB