<div class="well">
<h2>Top 5 Level</h2>
<?php
$cache = new Cache('engine/cache/topPlayer');
if ($cache->hasExpired()) {
    $players = mysql_select_multi("SELECT `name`, `level`, `experience` FROM `players` ORDER BY `experience` DESC LIMIT 5;");

    $cache->setContent($players);
    $cache->save();
} else {
    $players = $cache->load();
}?> <table class="table table-striped table-hover">
<?php

$count = 1;
foreach($players as $player) {
{echo "<TR><TD><strong>$count.</strong></TD>";
echo "<TD><a href='characterprofile.php?name=". $player['name']. "'>". $player['name']. "</a></TD>";
echo "<TD>Lvl.". $player['level'] ."<br></span></TD></TR>";
    echo '</TR>';}
    $count++;

}

?></table></span>




我想将此span(span class="label label-info">)添加到第三张表(Lvl.". $player['level'])中。

我尝试了很多事情,但无法正常工作。
请帮我。
谢谢你的时间!

最佳答案

echo '<TD><span class="label label-info">Lvl.'. $player['level'] .'<br></span></TD></TR>';


更改为单引号,因为您没有使用字符串插值功能,所以也没有理由使用双引号。

整个事情可能更容易读写。您也有怪异的大括号和引号。

foreach($players as $player) {
    $row = <<<ROW <tr>
    <td><strong>$count</strong></td>
    <td><a href="characterprofile.php?name={$player['name']}">{$player['name']}</a></td>
    <td><span class="label label-info">Lvl.{$player['level']}<br></span></td>
    </tr>
ROW;
    echo $row;
    $count++;
}

09-25 14:45