控制器层

  public function oldlist()
    {
//          体质监测列表
        $count  = Db::name('old_people_answer')->group('patient_name')->count();
        $result = Db::name('old_people_answer')
            //查询所需值
            ->field('number,created_at,result,community_doctor_name,patient_name')
            ->group('number')
            ->group('created_at')
            //第一个参数是每页数据量,第二个参数是总共有多少数据
            ->paginate(5,$count);

        // 获取分页显示
        $page = $result->render();
        // 模板变量赋值
        $this->assign('page', $page);
        $this->assign('data',$result);
        return $this->fetch();
    }

视图层一般用foreach进行遍历

tp5的数据查询,分页及数据遍历



tp5的数据查询,分页及数据遍历

tp5的数据查询,分页及数据遍历

tp5手册中的坑,它遍历是用{foreach},我的确需要用<foreach></foreach>

相关文章:

  • 2021-05-17
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
猜你喜欢
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案