Postingan lainnya
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.
1 Jawaban:
coba gini mas
<pre> 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> </pre>