为什么我的PHP查询显示空白结果

时间:2019-03-29 17:58:27

标签: php html mysql variables

我的查询在选择框中回显了正确数量的结果,但它们都为空?超级困惑任何帮助赞赏

<?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>

1 个答案:

答案 0 :(得分:2)

我想您正在尝试从数据库中获取team_name而不是cup_name,因此它将是:

$teamSet = $mysqli->query("SELECT team_name FROM teams WHERE cup_name='$cupsession'");