首页 > 开发 > MySQL > 正文

thinkphp如何让此代码循环输出

2017-09-08 08:50:51  来源:网友分享

用volist对repairman进行了循环遍历,由于count是根据repairman中wxid的值来统计在RepairInfo表中的数据条数,repairman可以循环输出,但是怎么也让count根据wxid的循环出处对应的值?

表述可能不太准确,不知道大佬们能听明白不?

前端模板代码

<p class="small-title">编号:{$repairmans.number}</p><div class="price-box clearfix">    <p class="now-price">完成维修:{$count}次</p></div><p class="small-title">电话:{$repairmans.tel}</p>

后端Controller层代码

 $repairman = D('Repairman')->getRepairman(); $wxid = $repairman['number']; $count = D('RepairInfo')->countRepairInfoByWxid($wxid); $this->assign('count',$count); $this->assign('repairman',$repairman); $this->display();

解决方案

换了种思路解决的,在repairman表中添加了一个count字段用于记录,每操作一次,count+1