我有一个名为Entry的表。此表有一个名为' course_type'的列。这是ENUM并持有价值('当然','研讨会')。如何在下拉列表中显示这些值?这是我到目前为止所尝试的:
<?php
$query = "SELECT course_type FROM entry ORDER BY name ASC";
$result = mysqli_query($con, $query);
?>
<form method="POST" action="/admin/entry/">
<select name="course_type">
<option value="0">$course_type</option>
<?php
while($row = mysqli_fetch_array($result))
{
?>
<option value = "<?php echo($row['course_type'])?>" >
<?php echo($row['course_type']) ?>
</option>
<?php
}
?>
</select>
</form>
&#13;
答案 0 :(得分:-1)
替换为以下
<select name="course_type">
<?php
<option value="0">--select--</option>
while($row = mysqli_fetch_object($result))
{
?>
<option value = "<?php echo $row->course_type; ?>" >
<?php echo $row->course_type; ?>
</option>
<?php
}
?>
</select>