/** * 获奖记录 */public function history(){ $page = max(1,$_GET['page']);//当前页 if(isset($_GET['page_total']) && $page > $_GET['page_total']) $page = $_GET['page_total'];//如果超出页数,就等于最大页数 $offset = ($page - 1) * 10; $results = $this->score->order('createtime desc')->limit($offset.',10')->select(['user_id'=>$_SESSION['user']['id']],'id,name,score,after,createtime,memo'); //总条数 $page_num = $this->score->count(['user_id'=>$_SESSION['user']['id']]); //总页数 $page_total = ceil($page_num/10); include HOME . '/View/draw/history.html';}
HTML代码
<div class="ps-lt"> <div class="lt-dsb b_info" style="text-align: center"> <p>第<?php echo $page?>页/共<?php echo $page_total?>页 <font color="green"> <a href="./index.php?c=draw&a=history&page=<?php echo $page-1;?>">上一页</a> <?php if($page < 3){ $j_start = 1; $j_end = $page_total > 4 ? 5 : $page_total; }else{ $j_start = $page - 2; $j_end = $page_total-$page >= 2 ? $page+2 : $page_total; } ?> <?php for($j=$j_start;$j<=$j_end;$j++){?> <a href="./index.php?c=draw&a=history&page=<?php echo $j;?>" <?php if($page == $j) echo 'style="color: red"';?>><?php echo $j;?></a> <?php }?> <a href="./index.php?c=draw&a=history&page=<?php echo $page+1?>&page_total=<?php echo $page_total?>">下一页</a></font></p> </div></div>
效果展示
来源:https://www.cnblogs.com/youantianqin/p/12272870.html