1 回答
TA贡献1860条经验 获得超9个赞
不要让它太复杂。有多种方法可以做到这一点,但这echo "<option value="<?php echo htmlentities($results->D_ID);?>"><?php echo htmlentities($results->D_NAME);?></option> <?php"; 是错误的不要将自己与关闭,打开php标签混淆,尝试以下
<?php
include('incl/conn.php');
if(!empty($_POST['specilization']))
{
$specilization =:$_POST['specilization'];
$sql = "SELECT D_ID, D_NAME FROM tbldoctor
WHERE D_SPECILIZATION=:specilization";
$query = $dbh->prepare($sql);
$query->bindParam(':specilization',$specilization,PDO::PARAM_STR);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
echo '<option selected="selected">Select Doctor</option>';
if($query->rowCount() > 0)
{
foreach($results as $results)
{
echo '<option value="'.htmlentities($results->D_ID).'">'. htmlentities($results->D_NAME).'</option>';
}
}
else
{
echo '<option value=""> No Doctor in this specilization</option>';
echo "<script>$('#submit').prop('disabled',true);</script>";
}
}
?>
- 1 回答
- 0 关注
- 152 浏览
添加回答
举报