Dropdown dari database di modal bootstrap

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 :

Pabrikan

-- Pilih --manufacturer_name;?>

terima kasih.

avatar fajar22
@fajar22

1 Kontribusi 0 Poin

Diperbarui 5 tahun yang lalu

1 Jawaban:

coba gini mas

<pre> select class="form-control" id="id" name="idkategori"&gt; &lt;option value=""&gt;--Piih Kategori--&lt;/option&gt; &lt;?php foreach ($manufaktur as $row ){ echo "&lt;option value ='".$row-&gt;idkategori."'&gt;".$row-&gt;nama_kategori."&lt;/option&gt;"; echo $row-&gt;idkategori==$manufaktur['idkategori']?'selected':''; } echo"&lt;/select&gt;"?&gt; &lt;/select&gt; </pre>

avatar Prasjo
@Prasjo

4 Kontribusi 1 Poin

Dipost 5 tahun yang lalu

Login untuk ikut Jawaban