<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']
)。
我尝试了很多东西,但我无法让它发挥作用。 请帮我。 谢谢你的时间!
答案 0 :(得分:2)
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++;
}
答案 1 :(得分:0)
你想从这一行:echo "<TD>Lvl.". $player['level'] ."<br></span></TD></TR>";
有这个吗? echo "<TD><span class='label label-info'>Lvl.". $player['level'] ."<br></span></TD></TR>";