Guest User

Klo yg ini salah di mana Gan ??

a guest
Aug 27th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. Model
  2. M_appunasa.php
  3. function get_kategori() {
  4.         $data = array();
  5.         $query = $this->db->get('kategori_produk');
  6.         if ($query->num_rows() > 0) {
  7.             foreach ($query->result_array() as $row){
  8.                     $data[] = $row;
  9.                 }
  10.         }  
  11.         $query->free_result();
  12.         return $data;  
  13.     }
  14.  
  15. Controller
  16. C_appunasa.php
  17. function dynamic_combobox(){
  18.  
  19.      // retrieve the states and add to the data array              
  20.         //$this->load->model('M_appunasa');    
  21.         $data['hasil'] = $this->M_appunasa->get_kategori();
  22.         $this->load->view('appunasa/tambah_produk', $data);
  23. }
  24.  
  25. View
  26. tambah_produk.php
  27.     <?
  28.     echo "<select name='id_kategori' id='id_kategori'>";
  29.     if (count($hasil)) {
  30.     foreach ($hasil as $list) {
  31.         echo "<option value='". $list['id_kategori'] . "'>" . $list['nama_kategori'] . "</option>";
  32.     }      
  33.     }  
  34.     echo "</select>";
  35.     ?>
Advertisement
Add Comment
Please, Sign In to add comment