我的查询在选择框中回显了正确数量的结果,但它们都为空?超级困惑任何帮助赞赏
<?php
session_start();
$cupsession = $_SESSION['c_cname'];
$teamSet = $mysqli->query("SELECT cup_name FROM teams WHERE cup_name='$cupsession'");
?>
<select name="team-1" required>
<option value='Holder' disabled selected>Team 1</option> <!--Placeholder for Select-->
<?php
while($rows = $teamSet->fetch_assoc()){ //Fills select with cup entries in db
$teamName = $rows['team_name'];
echo " <option value='$teamName'>$teamName</option>";
}
?>
</select>
答案 0 :(得分:2)
我想您正在尝试从数据库中获取team_name而不是cup_name,因此它将是:
$teamSet = $mysqli->query("SELECT team_name FROM teams WHERE cup_name='$cupsession'");