如何从表格中提取值并在组合框中选择值,以使结果不如下所示
<?php
$id = @$_GET['id'];
$query = "SELECT id_rm, tb_rekammedis.id_pasien, nama_pasien, keluhan, tb_rekammedis.id_dokter, nama_dokter, diagnosa, tb_rekammedis.id_poli, nama_poli, tgl_periksa
FROM tb_rekammedis
INNER JOIN tb_pasien USING(id_pasien)
INNER JOIN tb_dokter USING(id_dokter)
INNER JOIN tb_poliklinik USING(id_poli) WHERE id_rm='$id'";
$sql_pasien = mysqli_query($con, $query) or die(mysqli_error($con));
$data = mysqli_fetch_array($sql_pasien);
?>
<label for="pasien">Nama Pasien</label>
<select name="pasien" id="pasien" class="form-control" required>
<option value="<?=$data['id_pasien']?>" selected="selected"><?=$data['nama_pasien']?></option>
<option value="">- Pilih Pasien -</option>
<?php
$sql_pasien = mysqli_query($con, "SELECT * FROM tb_pasien") or die(mysqli_error($con));
while($data_pasien = mysqli_fetch_array($sql_pasien)) {
echo '<option value="'.$data_pasien['id_pasien'].'">'.$data_pasien['nama_pasien'].'</option>';
}
?>
</select>
如何从表格中提取值并在组合框中选择