简体   繁体   中英

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. it needs to be static befor the 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++;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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