Advertisement
gundambison

perbaikan 83 - pagination

Aug 31st, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.72 KB | None | 0 0
  1. <?php
  2. // CONTROLLER
  3. public function index()
  4.    {    
  5.       // get pagianation    
  6.       $this->load->library('pagination');
  7.       $config['base_url'] = site_url('home/index') ;
  8.       $config['uri_segment'] = 3;
  9.       $config['per_page'] = 3;
  10.       $config['total_rows'] = $this->mdl_home->record_count_product();
  11.  
  12.       $this->pagination->initialize($config);
  13.       $page = 4this->input->get('per_page' );//$this->uri->segment(3,0);
  14.       $data['pagination'] = $this->pagination->create_links();
  15.       $data['product'] = $this->mdl_home->tampil_data_product($config['per_page'], $page);
  16.  
  17.       $this->load->view('view_home', $data);
  18.    }
  19. ?>
  20. <!--// MODEL-------------->
  21. <?php
  22. defined('BASEPATH') OR exit('No direct script access allowed');
  23.  
  24. class Mdl_home extends CI_Model{
  25.  
  26.    var $tbl_product  = 'dt_product';
  27.  
  28.    public function __construct()
  29.    {
  30.       parent::__construct();
  31.    }
  32.  
  33.    public function tampil_data_product($limit, $start)
  34.    {
  35.       $this->db->limit($limit, $start);
  36.       $query = $this->db->get($this->tbl_product);
  37.       if($query->num_rows() > 0){
  38.          return $query->result();
  39.       }else{
  40.          return false;
  41.       }
  42.    }
  43.  
  44.    public function record_count_product()
  45.    {
  46.       $query = $this->db->count_all($this->tbl_product);
  47.       return $query;
  48.    }  
  49. }
  50.  
  51. // VIEW
  52. <div class="tab-pane fade" id="marketplace">
  53.                                     <div class="padding-gutter">
  54.                                        <?php
  55.  
  56.                                        foreach($product as $data) { ?>
  57.                                          
  58.                                           <div class="col-sm-6 col-md-6 col-lg-4">
  59.                                              <!-- product -->
  60.                                              <div class="product-content product-wrap clearfix">
  61.                                                 <div class="row">
  62.                                                       <div class="col-md-5 col-sm-12 col-xs-12">
  63.                                                          <div class="product-image">
  64.                                                             <img alt="194x228" class="img-responsive" src="<?php echo $data->img; ?>">
  65.                                                             <span class="tag2 sale">
  66.                                                                Sale
  67.                                                             </span>
  68.                                                          </div>
  69.                                                       </div>
  70.                                                       <div class="col-md-7 col-sm-12 col-xs-12">
  71.                                                       <div class="product-deatil">
  72.                                                             <h5 class="name">
  73.                                                                <a href="#">
  74.                                                                   <?php echo $data->nama_product; ?> <span>Category</span>
  75.                                                                </a>
  76.                                                             </h5>
  77.                                                             <p class="price-container">
  78.                                                                <span style="font-size:14px;">Rp. <?php echo number_format($data->harga,2,",",".");?></span>
  79.                                                             </p>
  80.                                                             <span class="tag2 sale"></span>
  81.                                                       </div>
  82.                                                       <div class="description">
  83.                                                             <p><?php echo $data->img; ?></p>
  84.                                                       </div>
  85.                                                    </div>
  86.                                                 </div>
  87.                                              </div>
  88.                                              <!-- end product -->
  89.                                           </div>
  90.                                        <?php } ?>                                  
  91.                                     </div>
  92.                                    
  93.                                     <div class="padding-gutter">
  94.                                        <div class="text-center">
  95.                                           <ul class="pagination">
  96.                                              Halaman : <?php echo $pagination;?>
  97.                                           </ul>
  98.                                        </div>
  99.                                     </div>
  100.                                  </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement