使用populate下拉列表将数据插入mysql

时间:2016-02-23 09:37:23

标签: php mysql

我正在尝试将数据插入到我的数据库表名dokter和poliklinik的填充下拉列表中。但是当我试图插入它时,通知会继续显示“unifined vaiable:kodep”

这里是表单代码

<select class="form1" name="Kodecrot">
            <?php
            $query = mysql_query("select * from poliklinik");
            if(mysql_num_rows($query) != 0) {
                while($tampil = mysql_fetch_array($query)){
                    echo "<option value=".$tampil['Namapoli'].">".$tampil['Namapoli']."</option>";
                }
            }
            ?>
            </select>

这里是流程代码

<?php
include'../koneksi.php';
$KodeDokter = $_POST['KodeDokter'];
$NmDokter = $_POST['NmDokter'];
$AlmDokter = $_POST['AlmDokter'];
$Telp = $_POST['Telp'];
$KodePoli = $_POST['Kodecrot'];
$KodeJadwal = $_POST['KodeJadwal'];
$med = mysql_query("select * from poliklinik where Namapoli = '$KodePoli'");
while($data = mysql_fetch_array($med)){
    $name = $data['Namapoli'];
    $kodep = $data['Kodepoli'];
}
$jad = mysql_query("select * from jadwalpraktek where Hari = '$KodeJadwal'");
while($data1 = mysql_fetch_array($jad)){
    $jadwal = $data1['Hari'];
    $jaks = $data1['KodeJadwal'];
}
mysql_query("insert into dokter(KodeDokter, NmDokter, AlmDokter, Telp, Kodepoli, KodeJadwal)values('$KodeDokter','$NmDokter','$AlmDokter','$Telp','$kodep','$jaks')");
?>

0 个答案:

没有答案