我正在尝试创建一个下拉列表,其中包含名为services的数据库表中的服务。下拉列表与提交按钮一起显示,但我的表中的三个选项都没有出现。
<!DOCTYPE>
<html>
<head>
<title> Search Services</title>
</head>
<body>
<form name ="searchform" method="post" action="search.php">
<?php
$conn = mysqli_connect("localhost", "eric",
"password", "ebeichner")
or die("Cannot connect to database:" .
mysqli_connect_error($conn));
echo "<select service= 'service'>";
echo '<option value="">'.'Please Select Service'.'</option>';
$query = mysqli_query($conn, "SELECT service FROM services");
$query_display = mysqli_query($conn, "SELECT * FROM services");
while($row=mysqli_fetch_array($query))
{
echo "option value='". $row['service']."'>".$row['service']
.'</option>';
}
echo '</select>';
?> <input type="submit" name="submit" value="submit"/>
</form>
</body>
<html>
答案 0 :(得分:0)
您错过了&#39;&lt;&#39;
echo "<option value='" . $row['service']. "'>" . $row['service'] . '</option>';