简体   繁体   English

数值统计表PHP MYSQL

[英]Numeric stats table PHP MYSQL

I have a stats table now. 我现在有一个统计表。

But what i want is this: 但是我想要的是:

1.|Team
2.|Team
3.|Team

I dont have de numbers before the teams. 我在球队之前没有人数。 My table is ordered by "Punten" so it can't be added with a team. 我的桌子是由“ Punten”排序的,因此无法与团队一起添加。 it needs to be static befor the td 在td之前它必须是静态的

This is my code: 这是我的代码:

    <?php
        $table = "e2teams";
        $sql = "SELECT ID, Team, Punten, Gespeeld, Gewonnen, Verloren, Gelijk, DPV, DPT, DPV-DPT AS Verschil FROM e2teams ORDER BY Punten DESC, Verschil DESC, DPV DESC";
        $result = mysql_query($sql, $dbhandle);


        echo "<table class='opmaaktable'><tr><td class='styled-td'>Team</td><td class='styled-td2'>G</td><td class='styled-td2'>W</td><td class='styled-td2'>GL</td><td class='styled-td2'>V</td><td class='styled-td2'>P</td><td class='styled-td2'>DPV</td><td class='styled-td2'>DPT</td><td class='styled-td2'>Vers.</td></tr></table>";  


        if(mysql_num_rows($result) > 0){
            $team = array();
            while($row = mysql_fetch_array($result)) {

                echo "<table><tr><td class='styled-td'>";
                echo $row['Team']. '</td><td class="styled-td2">';
                echo $row['Gespeeld']. '</td><td class="styled-td2">';
                echo $row['Gewonnen']. '</td><td class="styled-td2">';
                echo $row['Gelijk']. '</td><td class="styled-td2">';
                echo $row['Verloren']. '</td><td class="styled-td2">';
                echo $row['Punten']. '</td><td class="styled-td2">';
                echo $row['DPV']. '</td><td class="styled-td2">';
                echo $row['DPT']. '</td><td class="styled-td2">';
                echo $row['Verschil']. '</td><td class="styled-td2">';
                echo "</td></tr></table>";
                $team = $row['Team'];
                }
        }

    ?>

And this is how it looks like: 这是这样的: 在此处输入图片说明

Hope you can help! 希望能对您有所帮助!

I'm not sure if I'm missing something - but why not just declare a counter and increment it in the loop? 我不确定是否遗漏了什么-但是为什么不只声明一个计数器并在循环中增加它呢?

$ctr = 1;
while($row = mysql_fetch_array($result)) {

    echo "<table><tr><td class='styled-td'>";
    echo "$ctr." . $row['Team']. '</td><td class="styled-td2">';
    ...
    $ctr++;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM