私はsmartyに問題があります。実際、DBから収集したデータをループできません。
これはgetreputation関数です
function getreputation($username)
{
global $rDB;
$rows = $rDB->select('
SELECT *
FROM account_reputation
WHERE username=?
ORDER BY id DESC
',
$username
);
foreach($rows as $row)
{
$reputation = array();
$reputation['user'] = $row['username'];
$reputation['reputation'] = $row['reputation'];
$reputation['action'] = $row['reason'];
$reputation['date'] = $row['date'];
}
return $reputation;
}
この関数をtplに割り当てる方法は次のとおりです
$smarty->assign('reputation', getreputation($page['username']));
そして最後に、これは foreach ループです
{foreach from=$reputation item=reputation}
<tr><td width="33%"><center>
{if $reputation.action == 1}Registering an account
{elseif $reputation.action == 2}Daily visit
{elseif $reputation.action == 3}Posting a comment
{elseif $reputation.action == 4}Your comment was voted up (each upvote)
{elseif $reputation.action == 5}Submitting a screenshot
{elseif $reputation.action == 6}Submitting a guide (approved)
{elseif $reputation.action == 7}Earning a <font color="brown">Copper</font> <a href="/?website-achievements">website achievement</a>
{elseif $reputation.action == 8}Earning a Silver <a href="/?website-achievements">website achievement</a>
{elseif $reputation.action == 9}Earning a <font color="gold">Gold</font> <a href="/?website-achievements">website achievement</a>
{else}Achievement not found
{/if}
</center></td><td width="33%">
<center><font color='green'>+{$reputation.reputation}
</font></center></td><td width="33%"><center>
{$reputation.date}
</center></td></tr>
{/foreach}
私が見ることができるのは
したがって、 foreach の出力は完全に間違っています 誰かがこの問題を解決するのを手伝ってくれますか?