我在以 php 形式从 mysql 填充下拉列表时遇到问题。数据库连接就好了。但是下拉菜单返回空。我有两张桌子。(id, name, age, etc) and admissions (admissionid, year) 每个招生可以没有学生。但每个学生只能有一年的入学时间。我正在尝试这段代码:
<?php
ob_start();
session_start();
include ('database_connection.php');
$Studentid = $_SESSION['Studentid'];
$sql = "SELECT Admissionid FROM admissions";
$result = mysqli_query($sql);
echo $result;
$dropdown = "<select name='admission_year'>";
while($row = mysqli_fetch_assoc($result)) {
$dropdown .= "\r\n<option value='{$row['Admissionid']}'>{$row['Admissionid']} </option>";
}
$dropdown .= "\r\n</select>";
echo $dropdown;
?>