dongmiao260399 2015-09-06 01:42
浏览 19

使表头正确定位的问题

I am having difficulties with a table I am trying to create.

I have a users array that displays the users in my database table. There is 10 users in this. Then I should have 14 players under each user. Like this...

user1 user2 user3

player1 player1 player1

player2 player2 player2

player3 player3 player3

etc..

Right now it is doing this

enter image description here

Here is my code...

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

What am I doing wrong?

UPDATE:

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

enter image description here

  • 写回答

1条回答 默认 最新

  • dongwei2610 2015-09-06 04:17
    关注

    Try this:

    <table class="draft_border_table">
        <tr>
            <th>Rnd</th>
    <?php
    
    while ($draft_user_row = mysqli_fetch_array($draft_order_stmt2)) {
    
        $username = $draft_user_row['username'];
    
        echo "<th><div>" . $username . "</div></th>";
    
    }
    ?>
    
        </tr>
    
    <?php
    for ($count = 1; $count < 15; $count++) {
    
        $col = "player" . $count;
        $query = "SELECT $col FROM user_players ORDER BY id";
        $draft_order_stmt = mysqli_query($con, $query);
    
        echo "<tr><td>" . $count . "</td>";
    
        while (list($players) = mysqli_fetch_array($draft_order_stmt)) {
    
            echo "<td><div class=\"draftBorder\">";
    
            if ($players == NULL) {
    
                $players = "&nbsp;";
    
            }
    
            echo $players . "</div></td>";
    
        }
    
        echo "</tr>";
    }
    ?>
    </table>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口