Advertisement
GWibisono

Untitled

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