Postingan lainnya
drop down list database
<div class="form-group">
<label class="control-label col-md-3">Keadaan Barang</label>
<div class="col-md-9">
<textarea name="keadaan_barang" placeholder="Keadaan Barang" class="form-control"></textarea>
<span class="help-block"></span>
</div>
</div>
cara membuat drop down list database gimana ya ???
0
3 Jawaban:
buat dulu query select data nya, kemudian load data dalam
<select></select>
contoh
<div class="col-md-6">
<label for="exampleInputEmail1">Label</label>
<div class="input-group">
<select class="form-control" id="#" name="#">
<option value="">--example--</option>
<?php
foreach ($data as $item) {
echo "<option value='".$item->example."'>".$item->example."</option>";
}
?>
</select>
</div>
</div>
1
Misal : Dicontroller ngeparsing $data dari query database di fungsi load_view:
<ul class="dropdown-menu">
<?php foreach($data->result() as $row) { ?>
<li><?php echo $row->value; ?></li>
<?php } ?>
</ul>
0
buat function dulu untuk ambil data nya di model
function get_table(){ return $this->db->get('nama_tabel'); }
buat controllernya
$data['dropdown']=$this->model->get_table()->result();
buat view
nama ?>
0