Advertisement
Guest User

MVC

a guest
Jan 14th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. #Controller
  2. class Test extends CI_Controller {
  3.    
  4.         public function index()
  5.         {
  6.             $this->load->model('Testmodel');
  7.             $data=array(
  8.                 'barang'=>$this->Testmodel->getbarang()
  9.             );
  10.             $this->load->view('testindex', $data);
  11.         }
  12.    
  13.     }
  14.  
  15. #Model
  16. class Testmodel extends CI_Model {
  17.  
  18.     function getbarang(){
  19.         return $this->db->get('produk')->result();
  20.         //Sesuaikan  nama tabelnya
  21.     }
  22.  
  23. }
  24.  
  25. #View
  26. <form action="<?=base_url('test/post')?>" method="post">
  27.     <input type="number" name="mutasi" id="" placeholder="No. Mutasi">
  28.     <input type="text" name="kode" id="" placeholder="Kode Ruang">
  29.     <select name="barang" id="">
  30.         <option value="">Pilih Barang</option>
  31.         <?php
  32.             foreach($barang as $key){
  33.                 ?>
  34.                 <option value="<?=$key->id_produk?>"><?=$key->nama_produk?></option>
  35.                 <?php
  36.             }
  37.         ?>
  38.     </select>
  39. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement