Daftar dan Belajar Sekarang!

Dropdown dari database di modal bootstrap

foto fajar22
1 Kontribusi 0 Coto
1 minggu yang lalu
maaf newbie mau bertanya kpd suhu2 disini, ane mau buat dropdown di modal bootstrap yang mengambil dari database tetapi selalu error undefined variable model : public function getManufacturer(){ $hasil=$this->db->get('ac_manufacturer'); return $hasil; } public function simpan_product_all1($product_code,$manufacturer_id,$category_id,$sub_category_id,$name,$weight,$description,$link_tokopedia,$link_bukalapak,$link_shopee,$status_id,$quantity,$price,$aktif){ $hasil=$this->db->query("INSERT INTO ac_product ( product_code,status_id,quantity,price) VALUES ($product_code,$manufacturer_id,$category_id,$sub_category_id,$name,$weight,$description,$link_tokopedia,$link_bukalapak,$link_shopee,$status_id,$quantity,$price,$aktif)"); return $hasil; } controller : public function simpan_product_all(){ $product=$this->Product_model; $data["manufacturer"]=$this->Product_model->getManufacturer(); $product->simpan_product_all1(); $this->load->view("ngadimin/product",$data); } view : <div class="form-group"> <label class="control-label col-xs-3" >Pabrikan</label> <div class="col-xs-8"> <select required name="manufacturer_id" class="form-control"> <option value="" selected>-- Pilih --</option> <?php if (is_array($manufacturer)) { ?> <?php foreach($manufacturer as $row): {?> <option value="<?php echo $row->manufacturer_id;?>"><?php echo $row->manufacturer_name;?></option> <?php } endforeach;?> <?php } ?> </select> </div> </div> terima kasih.

Jawaban
foto verified logo Prasjo
4 Kontribusi 1 Coto
5 hari yang lalu
coba gini mas
select class="form-control" id="id" name="idkategori">
<option value="">--Piih Kategori--</option>
<?php foreach ($manufaktur as $row ){
echo "<option value ='".$row->idkategori."'>".$row->nama_kategori."</option>";
echo $row->idkategori==$manufaktur['idkategori']?'selected':'';
} 
echo"</select>"?>
</select>


Login untuk diksusi di forum sekolah koding