我有以下代码来显示基于 sql 查询的下拉列表,但是当我运行代码时没有显示任何内容。
<?php
require ("common.php");
$sql = "SELECT FullName FROM Users";
$query = $db->prepare($sql);
$query->execute();
$option = "";
while($rows = $query->fetchAll(PDO::FETCH_ASSOC)) {
$name = $rows["FullName"];
$option.="<option>".$name."</option>";
}
?>
<div class="aClass">
<p class="select">Name</p>
<select name="aName" id="aName">
<option value="0">Select UserName</option>
<?php echo $option?>
</select>
</div>