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

Hi guys, I'm sorry to open a new topic, but I'm learning with Codeigniter, I read everywhere guides and help on the internet but did not find anything that really explained from scratch how to structure the pagination.

I've tried a lot of things and also tried here on the forum, doing so many tests, but nothing, just showing me the pagination but not working.

This is my controller about database results:

PHP Code:
class Post extends CI_Controller {
 
   
    public 
function __construct() {
 
       parent::__construct();
 
       $this->load->model('post_model');
 
       $this->load->helper('url_helper');
 
       $this->load->helper('text');
 
   }
 
   
    public 
function index() {
 
       $data['title'] = 'Site';
 
       $data['desc'] = 'Enter the description of this page index';
 
       $data['posts'] = $this->post_model->get_post();
 
       $this->load->view('templates/header'$data);
 
       $this->load->view('index'$data);
 
     


While this is the model, in a few words are exactly the code provided by the codeigniter user guide, about tutorials to create news.


PHP Code:
class Post_model extends CI_Model {
 
   
    public 
function __construct() 
 
   {
 
       $this->load->database();
 
   }
 
   
    public 
function get_post($slug FALSE
 
   {
 
       if ($slug === FALSE) {
 
           $this->db->select('id,slug,text,gender,age,views,time,status');
 
           $this->db->from('post');
 
           $this->db->where('status'1);
 
           $this->db->order_by('id''DESC');
 
           $query $this->db->get();
 
           return $query->result_array();
 
       }
 
       $this->db->set('views''views+1'FALSE);
 
       $this->db->where('slug'$slug);
 
       $this->db->update('post');
 
       $query $this->db->get_where('post', array('slug'=>$slug));
 
       return $query->row_array();
 
   


I have read this guide https://www.codeigniter.com/user_guide/l...on#example  but I can not personalize everything and then run it. Do I need to create a specific file controller? I do not know how to move.

Thanks to who will help me,
Reply


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



Theme © iAndrew 2016 - Forum software by © MyBB