我知道这是一个超级基本的问题,但我一整天都找不到答案。我试图在表中显示我的所有数据库行,而我的 while 循环只显示第一行。
我试图将 while 循环的条件更改为“mysqli_fetch_array”,然后甚至没有出现第一行。
echo "<table>";
echo "<tr>
<th>Match_Id</th>
<th>Home_Team</th>
<th>Away_Team</th>
<th>Result</th>
<th>season</th>
<th>notes</th>
<th>Goals_Sum</th>
</tr> ";
$sql = "SELECT * FROM PremierLeague";
`enter code here` $result = sqlsrv_query($conn, $sql);
while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) {
echo "<tr>";
$id = $row['id'];
echo "<td>$id</td>";
$Home = $row['Home'];
echo "<td>$Home</td>";
$Away = $row['Away'];
echo "<td>$Away</td>";
$result = $row['result'];
echo "<td>$result</td>";
$season = $row['season'];
echo "<td>$season</td>";
$notes = $row['notes'];
echo "<td>$notes</td>";
$home_goals= $row['home_goals'];
$away_goals= $row['away_goals'];
$GoalSum = $home_goals+$away_goals;
echo "<td>$GoalSum</td>";
echo "</tr>";
}
echo "</table>";
预期结果:包含数据库中所有行的表。实际结果:只有数据库的第一行
波斯汪
元芳怎么了