pageNum等于多少,获取当前url地址,显示的条数
<?php
$data=reclist("select*from ysc_detail");
$pageSize = 3; //显示的页面条数
$type=floor(count($data)/$pageSize);
if(is_float($type)==float){
$type=floor(count($data)/$pageSize)+1;
}
if($_GET['pageNum']!=''){
$pageNum=$_GET['pageNum'];
}else if($_GET['pageNum']==1){
$_GET['pageNum']='1';
}else if($_GET['pageNum']=='a'){
$pageNum = 1;
}else{
$pageNum = 1;
}
// $pageNum = 1; //页数
$r = reclist("select * from ysc_detail limit " . (($pageNum - 1) * $pageSize) . "," . $pageSize);
while ($obj = mysqli_fetch_object($r)) {
$array[] = $obj;
}
foreach($r as $k){
?>
<li class="cm-cl">
<div class="cm-fl">
<strong><?php echo substr($k['time'],8)?></strong>
<?php echo substr($k['time'],0,7)?>
</div>
<div class="cm-fr">
<div class="txt"><a href="#"><?php echo $k['title']?></a></div>
<div class="ly"><?php echo $k['source']?></div>
<div class="cnt"><a href="#"><?php echo substr($k['content'],0,66)?></a></div>
</div>
</li>
<?php }?>
</ul>
<div class="p-pageBar">
<!-- <a class="prev dis">上一页</a>
<a class="item cur"> 1</a>
<a class="item"> 2</a>
<a class="item"> 3</a>
<a class="item">...</a>
<a class="next">下一页</a> -->
<a class="item" href="<?php echo urlkill('',ture)?>&pageNum=1">首页</a>
<a class="item" href="<?php echo urlkill('',true);?>&pageNum=<?php echo $pageNum==1?1:($pageNum-1)?>">上一页</a>
<a class="item" href="<?php echo urlkill('',true);?>&pageNum=<?php echo $pageNum==$endPage?$endPage:($pageNum+1)?>">下一页</a>
<a class="item" href="<?php echo urlkill('',ture);?>&pageNum=<?php echo $type?>">尾页</a>
</div>
下面是tp5.0分页
参考原文:https://www.cnblogs.com/bk233/p/7641184.html
1:在extends新建pages文件夹把分页类放在这里面 地址https://gitee.com/dengpq/tp5.0/blob/master/page.php
2:配置中
'paginate' => [
'type' => 'pages\page',//分页类
'var_page' => 'page',
'list_rows' => 15,
],
3:php代码
修改后修改样式增加了指定页面跳转
实际效果图
$limit = $post['limit'];
$page = ($post['page']-1)*$limit;
$number_value = "select DATE_FORMAT(create_time,'%Y-%m-%d') as a_create_time
,(select account from pay_shop where id=a.shop_id) as account
,channel as channel
,(select sum(pay_money)/100 from pay_order where shop_id = a.shop_id and `status` = 1 and create_time between '$start' and '$end') as a_pay_money
,(select sum(ss_money)/100 from pay_order where shop_id = a.shop_id and `status` = 1 and create_time between '$start' and '$end') as a_ss_money
,SUM(money)/100 as money
,(select SUM(money)/100 from pay_withdrawal where shop_id = a.shop_id and create_time between unix_timestamp(a_create_time) and unix_timestamp(a_create_time)+60*60*24-1) as b_money
,(select balance from pay_shop_trade_log where shop_id = a.shop_id and create_time between a_create_time and from_unixtime(unix_timestamp(a_create_time)+60*60*24-1,'%Y-%m-%d %H:%i:%s') order by id desc limit 1) as c_money
from pay_order a
WHERE status = 1
AND create_time between '$start' and '$end'
group by a.shop_id,DATE_FORMAT(create_time,'%Y-%m-%d'),channel;
";
数组分页 $param['limit']每页条数 $page获取的当前页 $limit = $param['limit']; $page=($param['page']-1)*$limit; $res['data'] = array_slice($data,$page,$limit);