当前位置:网站首页>Thinkphp5.0 model operation uses page for paging
Thinkphp5.0 model operation uses page for paging
2022-07-19 03:37:00 【Curtain dust maple】
controller Controller code :
public function total(){
$data=$_GET;
// Pagination
$pagenum = isset($data['limit']) ? intval($data['limit']) : 6;
$page = isset($data['page']) ? intval($data['page']) : 1;
$typeid = isset($data['typeid']) ? trim($data['typeid']) : -1;
$db =WayAccount::where('system',1);
$typeid!=-1 && $db=$db->where('wayid',$typeid);
$list = $db->order('id desc')->select();
// How many pieces of data are there in all
$db =WayAccount::where('userid',session('userid'));
$typeid!=-1 && $db=$db->where('wayid',$typeid);
$count = $db->count('id');
// Calculate the total number of pages
$totalPage = (int)(($count + $pagenum -1) / $pagenum);
$this->assign('accountList',$list);
$this->assign("totalPage",$totalPage);
$this->assign("count",$count);
$this->assign("page",$page);
return view();
}view Template page code :
<!-- Pagination -->
{notempty name="accountList"}
<div class="layui-row" style="text-align: center;">
<div class="layui-box layui-laypage layui-laypage-default">
<span class="layui-laypage-count"> common {$count} strip </span>
<a href="javascript:;" onclick="gotoPage('{$page-1}')" class="layui-laypage-prev {if $page==1}layui-disabled{/if}"> The previous page </a>
{for start='1' comparison='<=' end=' $totalPage '}
{if condition="$i eq $page" /}
<span class="layui-laypage-curr"><em class="layui-laypage-em"></em><em>{$i}</em></span>
{else /}
<a href="javascript:;" onclick="gotoPage('{$i} ')">{$i}</a>
{/if}
{/for}
<a href="javascript:;" onclick="gotoPage('{$page+1} ')" class="layui-laypage-next {if $page==$totalPage}layui-disabled{/if}" > The next page </a>
</div>
</div>
{/notempty}
<script type="text/javascript">
function gotoPage(page){
var typeid =$("select[name='typeid ']").val();
formget("{:url('@Admin/Account/total ')}",{'typeid ':typeid,'page ':page});
}
/**
* simulation form Forms , Realization get Submit
* url: Request link
* data:json Format get Parameters
*/
function formget(url, data) {
var tempform = document.createElement("form");
tempform.action = url;
tempform.method = "get";
tempform.style.display = "none";
for (var x in data) {
var opt = document.createElement("textarea");
opt.name = x;
opt.value = data[x];
tempform.appendChild(opt);
}
document.body.appendChild(tempform);
tempform.submit();
}
</script>explain : Pagination uses layui The style of , The effect is as follows :

边栏推荐
- Leetcode: multiple knapsack problem in dynamic programming [one template solves all ~]
- Pure virtual function
- RuntimeError_ Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor)
- Ncnn allocator memory allocator
- ES6 learning notes - brother Ma at station B
- leetcode:78. 子集
- 机器学习库Scikit-Learn(线性模型、岭回归、插入一列数据(insert)、提取所需列、向量机(SVM)、聚类)
- Use RZ, SZ commands to upload and download files through xshell7
- Oracle queries the maximum partition of non self growing partition
- S32k148evb about eNet loopback experiment
猜你喜欢

374. 猜数字大小(入门 必会)

Paper reading: u-net++: redesigning skip connections to exploit multiscale features in image segmentation

2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)

10. Redis 面试常见问答

S32k148evb about eNet loopback experiment
![2022-07-16: what is the output of the following go language code? A:[]; B:[5]; C:[5 0 0 0 0]; D:[0 0 0 0 0]。 package main import ( “fmt“ )](/img/e4/ff7f1e19583f42377307de7291f870.png)
2022-07-16: what is the output of the following go language code? A:[]; B:[5]; C:[5 0 0 0 0]; D:[0 0 0 0 0]。 package main import ( “fmt“ )

Yolov5 ncnn reasoning

Envi: (the most detailed tutorial in 2022) custom coordinate system

MySQL master-slave setup

Polynomial interpolation fitting (I)
随机推荐
Vs code problem: launch:program '... \ vscode\launch. exe‘ dose not exist
論文閱讀:U-Net++: Redesigning Skip Connections to Exploit Multiscale Features in Image Segmentation
[MySQL] data query operation (select statement)
Net SNMP development I
Transaction and storage engine in MySQL database
Method of realizing horizontal and vertical centering of unknown width and height elements
ncnn DataReader&Extractor&blob
D. Permutation restoration (greedy / double pointer /set)
Binary search (leetcode704. very simple and necessary)
Use RZ, SZ commands to upload and download files through xshell7
[template record] string hash to judge palindrome string
MySQL log management and full backup incremental backup and recovery
Yolov6 learning first chapter
Automatic assembly & set injection
爬虫学习(5):手把手教你爬虫requests实战演练
MySQL optimized index
MYSQL主从搭建
Dqn theoretical basis and code implementation [pytoch + cartpole-v0]
Thinkphp5.0模型操作使用page进行分页
基于MFC如何实现单个文档的文件读写