<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++;
}
关于php - 我想在 php 文件中放置一个跨度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20804547/