Home  >  Q&A  >  body text

Pagination problem in thinkphp3.2.3

Thinkphp3.2.3’s paging problem is similar to Tieba. How many floors are there? I used a foreach loop and used the loop key value + 1 to achieve the first page of 1-10 floors. There is no Question, but when you go to the second floor, it is not the 11-20 floors, but the 1-10 floors. How can you solve this? I printed out the second page because it also started from the 0 key value, so it also ended up on floors 1-10

$count = $model_forum->where($forum_data)->count();//Query the total number of records that meet the requirements $map represents the query conditions

     $Page       = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(25)
    $show = $Page->show();// 分页显示输出
    // 进行分页数据查询
    $list = $model_forum->where($forum_data)->order('id')->limit($Page->firstRow.','.$Page->listRows)->select(); // $Page->firstRow 起始条数 $Page->listRows 获取多少条
    $this->assign('fenye',$list);// 赋值数据集
    $this->assign('page',$show);// 赋值分页输出
PHP中文网PHP中文网2683 days ago325

reply all(1)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 13:18:35

    Why do you write limit() like this? Why not just limit($page->firstRow,$page->listRows)?

    reply
    0
  • Cancelreply