codeigniter_test/application/controllers/blog.php

38 lines
968 B
PHP
Raw Permalink Normal View History

2020-01-02 22:49:45 +07:00
<?php
class Blog extends CI_Controller{
function __Construct()
{
parent ::__construct();
$this->load->model('M_post');
}
function index()
{
$this->load->model('M_post');
$this->db->select('*');
$this->db->from('post');
$getData = $this->db->get('');
$a = $getData->num_rows();
$config['base_url'] = base_url().'/blog/index'; //set the base url for pagination
$config['total_rows'] = $a; //total rows
$config['per_page'] = '5'; //the number of per page for pagination
$config['uri_segment'] = '3'; //see from base_url. 3 for this case
$this->pagination->initialize($config);
$data = array(
'judul' => 'Another Web',
'daftarpost' => $this->M_post->get_post_all($config['per_page'],$this->uri->segment(3))
);
$this->load->view('blog/vIndex',$data);
}
function post($id)
{
$data['judul']='Page';
$data['edit']=$this->M_post->edit_post($id);
$this->load->view('blog/vSingle',$data);
}
}