我在填寫表單中的選擇框以顯示來自「護士」表的護士的現有「姓名」時存在困難。誰能告訴我我做錯了什麼?提前致謝!用php mysql填充選擇框
這裏是形式
<form method="post" action="insert.php">
<br>
<tr><td align="left"><strong>Nurse Information</strong></td>
</td>
<tr>
<td>nurse_name</td>
<td><select name="valuelist">
<option value="valuelist" name="nurse_name" value='<?php echo $nurse_name; ?>'></option>
</select></td>
<tr>
應該填充nurse_forename查詢:
<html><head><title>Connect to Database</title></head><body>
<font size="4">Query gets Forename of nurse</font>
<br><br><font size="4">Choose a name</font><br><br>
<form action="insert.php" method="post">
<select name="valuelist">;
<?php
$value=$_POST ["valuelist"];
$con = mysql_connect("localhost","root","") or die('Could not connect: ' . mysql_error());
mysql_select_db("a&e", $con) or die('Could not select database.');
$fetch_nurse_name = mysql_query("SELECT DISTINCT $nurse_name FROM nurse");
$result = mysqli_query($con, $query) or die("Invalid query");
while($throw_nurse_name = mysqli_fetch_array($fetch_nurse_name)) {
echo '<option value=\"'.$nurse_name['nurse_name'].'">'.$throw_nurse_name['nurse_name'].'</option>';
}
echo "</select>";
mysqli_close($con);
?>
<input type="submit" value="Submit">
</form></body></html>
你會得到什麼錯誤? – d4rkpr1nc3 2013-02-15 13:00:54
沒有錯誤,只是一個空白的選擇框,這是相當令人沮喪的! – user2075528 2013-02-15 13:03:36
我想它不是'$ nurse_name',而是'nurse_name',在你的選擇查詢中 – d4rkpr1nc3 2013-02-15 13:04:40