我正在尝试使用来自 mysl db 的数据自动填充下拉菜单。下拉菜单应显示类型inactive
并active
供用户选择。下面我有来自 php 端的表结构和 sql 查询。下拉列表根本不显示任何值。
CREATE TABLE academy
(
academy_id int(11) not null auto_increment,
name varchar(25) not null,
type enum('INACTIVE','ACTIVE') DEFAULT 'ACTIVE' NOT NULL,
primary key (id),
);
php
Type: <select name="select_type">
<?php
$mysqli = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$dropDownQuery = "SELECT type FROM academy";
if ($result = $mysqli->query($dropDownQuery)) {
while ($row = $result->fetch_row()) {
$type = $row['type'];
echo "<option value=\"$type\">$type</option>";
}
}
?>
</select>