eg1:统计某个人表单向导中的信息数量,这张数据表叫v9_form_yuyue
{pc:get sql="SELECT count(*) as count FROM v9_form_yuyue" cache = "3600" return = "data"} {loop $data $v} 数据表v9_form_yuyue中共有 {$v[count]} 条信息 {/loop} {/pc}
觉得信息数量有点少?!还可以给它加一个基数:
{pc:get sql="SELECT count(*) as count FROM v9_form_yuyue" cache = "3600" return = "data"} {php $i=666;} {loop $data $v} <?php $v[count]=$v[count]+$i; echo $v[count]; ?> {/loop} {/pc}
eg2:统计文章模型数据表中某几个分类的文章数量(这张数据表叫v9_news,需要统计其中catid为1,2,3的文章数量)
{pc:get sql="SELECT count(*) as count FROM v9_news WHERE catid in (1,2,3)" cache="3600" return="data"} {loop $data $v} <p>数据表v9_news中catid为1,2,3的数据共有 {$v[count]} 条!</p> {/loop} {/pc}
有朋自远方来...评论一下呗O(∩_∩)O