【发布时间】:2015-10-19 05:53:14
【问题描述】:
我有下表,旨在显示输赢记录和排名。不过,我遇到了两个问题。
- 第一个问题是我的等级
<td>没有像我希望的那样进步。我的意思是对于循环和输出的每条记录,我希望它被编号。
即:
1
2
3 等
- 我想不通的第二部分是我希望获胜总数最高的人排名最高。我也希望将损失配置到其中。因此,如果某人是 5-0,他们的排名将高于某人的 5-1。
有人能指出我遇到的这些问题的正确方向吗?
<h2>Division 1</h2>
<table>
<tr>
<th>Rank</th>
<th>Name</th>
<th>Wins</th>
<th>Losses</th>
</tr>
<?php
try {
//Prepare
if ($stmt = $con->prepare("SELECT * FROM team_rankings WHERE `division`=1")) {
$stmt->execute();
$stmt->bind_result($ranking_id, $ranking_user_id, $ranking_firstname, $ranking_username, $ranking_division, $ranking_wins, $ranking_losses);
//var_dump($stmt);
if (!$stmt) {
throw new Exception($con->error);
}
$stmt->store_result();
while ($row = $stmt->fetch()) {
?>
<tr>
<td>1</td>
<td><?php echo $ranking_firstname; ?></td>
<td><?php echo $ranking_wins; ?></td>
<td><?php echo $ranking_losses; ?></td>
</table>
<?php
}
} else {
echo "<p>There aren't any players in division 1 yet.</p>";
}
}
catch (Exception $e)
{
echo "Error: " . $e->getMessage();
}
?>
【问题讨论】:
标签: php mysql while-loop html-table