简体   繁体   中英

Table count from 1 and up

I have a table on my website, where I basically want to count from 1 and up to 100 (100 is my amount of rows in the table), so basically it will look like this

Rank | Player     | Kills | Deaths  
===================================
   1 | ImSchnebz  |   100 |      24  
   2 | BedRockets |   45  |     485

and so on..

How would I do that with PHP?

Try iterating:

$c_rank = 0;
echo "Rank | Player | Kills | Deaths" . PHP_EOL;
for($ranks as $rank)
{
    $c_rank += 1;
    printf("%s | %s | %s | %s" . PHP_EOL, $c_rank, $ranks['player'], $ranks['kills'], $ranks['deaths']);
}

assuming those array keys exist in your players table.
(AND assuming you give the proper formatting. I did not give you the HTML formatting, but just the counter).

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