求助tp3.2的写法

浏览:440 发布日期:2020/07/05 分类:求助交流
IndexController.class.php
代码

---------------------------------------------------        $id = 1;
        $DB   = M('News');
        $count = $DB->where("pid = $id")->count();// 查询满足要求的总记录数
        $Pagegg  = new \Think\Page($count,5);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $showgg  = $Pagegg->show();// 分页显示输出
        $Infogg = $DB->where("pid = $id")->field('id,title,time')->order('time desc')->limit($Pagegg->firstRow.','.$Pagegg->listRows)->select();
--------------------------------------------

index.html代码

------------------------------------------      <foreach name="infogg" item="k">
        <tr>
          <td><a href="__ROOT__/news/index/id/{$k.id}.html" target="_blank"><if condition="mb_strlen($k['title'],'utf-8') egt 20">
    {$k.title|msubstr=0,20,'utf-8',true}
    <else/> 
    {$k.title}
    </if>
</if></a></td>

        </tr></foreach>
-----------------------------------------



模板想写2个东西,,那个$id是文章的栏目 ,,我要调用1和2在首页,要怎么写
最佳答案
评论( 相关
后面还有条评论,点击查看>>