【发布时间】:2015-12-01 20:42:37
【问题描述】:
我在尝试创建表格时遇到问题。
我有一个用户数组,用于显示我的数据库表中的用户。这里面有10个用户。那么我应该在每个用户下有 14 个玩家。像这样……
用户 1 用户 2 用户 3
玩家1 玩家1 玩家1
玩家2 玩家2 玩家2
player3 player3 player3
等等。
现在它正在这样做
这是我的代码...
<table class="draft_border_table">
<tr>
<th>Rnd</th>
<th><?php echo "<div>" . $draft_order_row['username'] . "</div>"; ?></th>
<?php
while($draft_order_row = mysqli_fetch_array($draft_order_stmt)) {
?>
</tr>
<tr>
<td><?php echo "<div class='draftBorder'>" . $player1 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player2 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player3 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player4 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player5 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player6 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player7 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player8 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player9 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player10 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player11 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player12 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player13 . "</div>"; ?></td>
<td><?php echo "<div class='draftBorder'>" . $player14 . "</div>"; ?></td>
</tr>
</table>
<?php
}
?>
我做错了什么?
更新:
<table class="draft_border_table">
<tr>
<th>Rnd</th>
<?php
while($draft_username_row = mysqli_fetch_array($draft_order_stmt2)) {
$username = $draft_username_row['username'];
?>
<th><?php echo "<div>" . $username . "</div>"; ?></th>
<?php
}
?>
</tr>
<?php
$count = 1;
while($draft_order_row = mysqli_fetch_array($draft_order_stmt)) {
$count + 1;
$player1 = $draft_order_row['player1'];
$player2 = $draft_order_row['player2'];
$player3 = $draft_order_row['player3'];
$player4 = $draft_order_row['player4'];
$player5 = $draft_order_row['player5'];
$player6 = $draft_order_row['player6'];
$player7 = $draft_order_row['player7'];
$player8 = $draft_order_row['player8'];
$player9 = $draft_order_row['player9'];
$player10 = $draft_order_row['player10'];
$player11 = $draft_order_row['player11'];
$player12 = $draft_order_row['player12'];
$player13 = $draft_order_row['player13'];
$player14 = $draft_order_row['player14'];
?>
<tr>
</tr>
<tr>
<td><?php echo $count; ?></td>
</tr>
<tr>
<td><?php echo "<div class='draftBorder'>" . $player1 . "</div>"; ?></td>
</tr>
<tr>
<td><?php echo "<div class='draftBorder'>" . $player2 . "</div>"; ?></td>
</tr>
【问题讨论】:
标签: php mysql loops while-loop html-table