Advertisement
Benvu

index.php

Mar 20th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.44 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Index extends CI_Controller {
  5.     public function __construct()
  6.     {
  7.         parent::__construct();
  8.         $this->load->model('m_produk');
  9.         $this->load->helper(['url','html','form']);
  10.         $this->load->database();
  11.         $this->load->library(['form_validation','session','pagination']);
  12.     }
  13.  
  14.     public function index()
  15.     {
  16.         $this->load->database();
  17.         $jumlah_data = $this->m_produk->jumlah_data();
  18.         $this->load->library('pagination');
  19.         $config['base_url'] = base_url().'http://localhost/rumah/index';
  20.         $config['total_rows'] = $jumlah_data;
  21.         $config['per_page'] = 10;
  22.         $from = $this->uri->segment(3);
  23.         $this->pagination->initialize($config);    
  24.         $data['produk'] = $this->m_produk->data($config['per_page'],$from);
  25.         $this->load->view('account/v_dashboard',$data);
  26.     }
  27.  
  28.     public function deskripsi($id){
  29.         $rules =    [
  30.                         [
  31.                                 'field' => 'caption',
  32.                                 'label' => 'Caption',
  33.                                 'rules' => 'required'
  34.                         ],
  35.                         [
  36.                                 'field' => 'description',
  37.                                 'label' => 'Description',
  38.                                 'rules' => 'required'
  39.                         ]
  40.                     ];
  41.  
  42.         $this->form_validation->set_rules($rules);
  43.         $image = $this->m_produk->find($id)->row();
  44.  
  45.         if ($this->form_validation->run() == FALSE)
  46.         {
  47.             $this->load->view('produk/deskripsi',['image'=>$image]);
  48.         }
  49.     }
  50. }
  51.  
  52. //controller
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement