PHP从MySQL填充值

时间:2017-03-07 10:06:35

标签: php mysql html5

这是我的代码:

<?php
$hostname = "localhost";
$username = "root";
$password = "";
$databasename = "change_management";    
$connect = mysqli_connect($hostname, $username, $password, $databasename);  
$query3 = "SELECT `change_id` FROM `change_request_tbl` WHERE `review_by` IS NULL";    
$result = mysqli_query($connect,$query3);
?>    
<select name="change_id">
<?php 
while ($row = mysqli_fetch_array($result))
{
echo "<option value='".$row['change_id']."'</option>";
}
?>    
</select>

如您所见,我正在尝试使用change_id值填充下拉菜单,其中字段review_by为空。目前,下拉菜单中有空白值。

我做错了什么?

1 个答案:

答案 0 :(得分:2)

您在<option>Your value here</option>

中错过了可见

尝试更改

echo "<option value='".$row['change_id']."'</option>";

echo "<option value='".$row['change_id']."'>".$row['change_id']."</option>";