tp5分頁案例

2021-10-07 10:03:23 字數 428 閱讀 6256

****本文純屬學習用途,簡單易上手*****

首先明確思路:

先通過get方式拿到當前頁碼,一頁展示5條,那麼limit的第乙個引數就是:(當前頁碼-1)*單頁展示數量,第二個引數是單頁展示數量。

controller頁面**

index.php

<?php

session_start();//啟用session,視需求而定

use think\db;//引入系統db類

use think\controller;//引入系統控制器類

class index extends controller

}

view檢視頁面**

list.html

TP5分頁樣式修改

基礎的分頁呼叫 控制器部分 例項化模型 areasmodel new areas 分頁資料集 listarea areasmodel paginate page 分頁顯示輸出 page listarea render 模板賦值 this assign listarea listarea this a...

tp5分頁器使用

分頁查詢 thinkphp5.0內建了分頁實現,要給資料新增分頁 出功能在5.0變得非常簡單,可以直接在db類查詢的時候呼叫paginate方法 查詢狀態為1的使用者資料 並且每頁顯示10條資料 list db name user where status 1 10 把分頁資料賦值給模板變數list...

tp5分頁去除重複值

total user alias u join contract c c.user id u.id left where page param count distinct u.name lists user alias u distinct true field u.id,u.name,u.pho...