im making a select option, the value is from the database, the CRUD
is working perfectly, but the value that i input from the select option is wrong, instead of the value the data that being inputted is the id of the data, this is my select option code
<select name="provinsi_dom" id="provinsi_dom">
<?php
//mengambil nama-nama provinsi yang ada di database
$sqlProvinsi_dom = mysqli_query($con,"SELECT * FROM provinsi ORDER BY nama_provinsi ASC");
echo "<option value=''>--Pilih Provinsi--</option>";
while($p=mysqli_fetch_array($sqlProvinsi_dom)){
if ($p['id_provinsi']==$provinsi_dom) {
$cek="selected";
}else {
$cek="";
}
echo "<option value='$p[id_provinsi]' $cek>$p[nama_provinsi]</option>" ;
}
?>
</select>
so instead of the data what being inputted is this
this is the select option value
After discusion in chat:
User want to save "nama_provinsi" in database. But for some reason, id_provinsi should not be changed in view/interface.
So, the edit should be in insert query. To get nama_provinsi by id_provinsi
...
( SELECT nama_provinsi FROM provinsi WHERE id_provinsi = $prov),
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.