2 回答
TA贡献1811条经验 获得超4个赞
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";
$result = sqlsrv_query($conn, $sql);
while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) {
$id = $row['id'];
$Home = $row['Home'];
$Away = $row['Away'];
$result = $row['result'];
$season = $row['season'];
$notes = $row['notes'];
$home_goals= $row['home_goals'];
$away_goals= $row['away_goals'];
$GoalSum = $home_goals+$away_goals;
echo $output.="<tr>
<td>$id</td>
<td>$Home</td>
<td>$Away</td>
<td>$result</td>
<td>$season</td>
<td>$notes</td>
<td>$GoalSum</td>
</tr>";
}
echo "</table>";
TA贡献1798条经验 获得超7个赞
您的代码示例乍一看很干净,但这仍然让我想起两种不同的可能性:
您的表格仅包含一行。这很愚蠢,但必须先检查。好吧,我想你做到了;
一个无关的分号“;” while()条件后忘记:
while($res=fetch(…));
{
display something…
}
在这种情况下,循环将迭代直到数据集结束,然后将输入大括号中的块(假设为孤立块),显示变量中剩余的内容。但在这种情况下,您应该获得查询的最后一行,而不是第一行。
- 2 回答
- 0 关注
- 265 浏览
添加回答
举报