I made 3 files (detail.php, edit.php and editdata.php)
detail.php shows the list of data from MySQL using select * from table where id='$id
and it's working. But it's not working for my <select>
. It still shows me the default value.
This is my db connection
<?php
include 'config.php';
$id=$_GET['id'];
$sqlTampil="select * from data_korban Where kasus_id=$id";
$qryTampil=mysql_query($sqlTampil);
$dataTampil=mysql_fetch_array($qryTampil);
$data=mysql_fetch_array($qryTampil);
?>
Code for another form (It works)
<input type="DATE" name="tanggal" size="20" value="<?php echo $dataTampil['tanggal']; ?>">
<input type="text" name="namakorban" size="40" value="<?php echo $dataTampil['namakorban']; ?>">
The code for select form (not working) (default value = Kota Mataram and the Selected value is Lombok Tengah)
<select name="kabupaten" id="kabupaten" value="<?php echo $dataTampil['kabupaten']; ?>">
<option value="Kota Mataram">Kota Mataram</option>
<option value="Lombok Barat">Lombok Barat</option>
<option value="Lombok Tengah">Lombok Tengah</option>
<option value="Lombok Timur">Lombok Timur</option>
<option value="Lombok Utara">Lombok Utara</option>
<option value="Sumbawa Besar">Sumbawa Besar</option>
<option value="Sumbawa Barat">Sumbawa Barat</option>
<option value="Kota Bima">Kota Bima</option>
<option value="Dompu">Dompu</option>
</select>
I'm a bit confuse on how to set values in select form.