Welcome Guest, Not a member yet? Register   Sign In
How to make paging from the basics
#10

controller

PHP Code:
   public function index() {
 
       $this->load->library('pagination');
 
       $offset 0;
 
       //per_page is the variable of pagination library, if you want you can change this variable name in pagination configs
 
       if ($this->input->get('per_page') != null) {
 
           $offset $this->input->get('per_page');
 
       }
 
       $count 5//number of posts in page 
 
       $filter = array();
 
       
        $data
['post_count'] = $this->post_model->get_total_post($filter);
 
       
        $data
['title'] = 'title';
 
       $data['desc'] = 'Enter the description of this page hot';
 
       $data['post'] = $this->post_model->get_hotPost($filter$count$offset);
 
       
        $config
['base_url'] = base_url() . 'hot';
 
       $config['total_rows'] = $data['post_count'];
 
       $config['per_page'] = $count;

 
       $this->pagination->initialize($config);
 
       $data['pagination'] = $this->pagination->create_links();
 
       
        $this
->load->view('templates/header'$data);
 
       $this->load->view('post/hot'$data);
 
   

Model

PHP Code:
   public function get_hotPost($filter$count$offset
 
   {
 
       $this->db->select('id,slug,text,gender,age,views,time,status');
 
       $this->db->from('post');
 
       $this->db->where('status'1);
 
       $this->db->order_by('views''DESC');
 
       $this->db->limit($count);
 
       $query $this->db->get();
 
       return $query->result_array();
 
   

Unfortunately I'm shown a lot of results (as I have set) and going to the next page shows me the same results. I do not understand why
Reply


Messages In This Thread
RE: How to make paging from the basics - by Marcolino92 - 08-10-2017, 05:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB