SHOW:
|
|
- or go back to the newest paste.
1 | - | Model |
1 | + | <?php |
2 | /*Model | |
3 | M_appunasa.php | |
4 | */ | |
5 | - | $query = $this->db->get('kategori_produk'); |
5 | + | |
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 | - | foreach ($hasil as $list) { |
30 | + | |
31 | - | echo "<option value='". $list['id_kategori'] . "'>" . $list['nama_kategori'] . "</option>"; |
31 | + | |
32 | - | } |
32 | + | |
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 | ?> |