这是finecms 的模板,有这样的一个循环,展示的是会员发内布的交易信息,每个信息里面又有其他会员的回复,这个回复里有金额,用PHP写了个运算(只是显示,没写入数据库),可是它只算两条以内的和,如何能让每个信息里的所有回执金额相加成总数呢?
{list modelid=27 order=updatetime num=10 more=1}
{php $id = $t['id'];}
<a href="{$t['url']}">
<li style="position:relative;">
<div class="jyxx">{strcut(strip_tags($t['shangjia']),12,"")}</div><div class="jyxx">{strcut(strip_tags($t['title']),12,"")}</div><div class="jyxx">{strcut(strip_tags($t['jiaoyixiangmu']),12,"")}</div><div class="jyxx">¥{$t['jiaoyijine']}元</div>
{list form=jiaoyi cid=$id order=id return=d}
<?php $a= $d['huizhijine']; $g = $d['lingqubili']; $dd = $c; $c = $a *100 /$g; $dd +=$c; $e = $d['jiaoyijine'] - $dd; $f = $e *$g /100; $h = $dd /$t['jiaoyijine'] *100;?>
<h1 class="indhz">最近领取:{date("Y年m月d日",$d['updatetime'])}来{$d['huizhishangjia']}领取{$d['huizhijine']} 元 {$d['huizhichanpin']}--计{$c}</h1>
{/list}
总{$dd}
</li>
</a>
{/list}
因为你的$dd变量定义在了循环里了,所以每次循环都会重置