SHARE
TWEET

MVC

a guest Jan 14th, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top