這个分页显示怎么只能显示俩页,要怎么修改
<?php
/**
* Created by PhpStorm.
* User: Jodo
* Date: 2017-04-17
* Time: 16:10
*/
$currentPageIndex = 1;//当前是第几页
$pageSize = 4;//每页显示3条
$totalPage = 0;//总共有多少页
$totalRecord = 0;//总记录条数
$absoluteIndex = 0;//记录的绝对定位
/**
* 完成分页显示的相关计划与控制
* $totalRecords 当前总的记录行数
*/
function _page($totalRecords)
{
global $currentPageIndex,$pageSize,$totalPage,$absoluteIndex,$totalRecord;
if(isset($_GET['pageIndex']))
{
$currentPageIndex = $_GET["pageIndex"];
if(empty($currentPageIndex) or $currentPageIndex < 0 or !is_numeric($currentPageIndex)){
$page = 1;
}else {
$currentPageIndex = intval($currentPageIndex);
}
}else{
$currentPageIndex = 1;
}
$totalPage = ceil($totalRecords / $pageSize);//ceil(5/2)=3
$absoluteIndex = ($currentPageIndex - 1) * $pageSize;
}
function _paging($pagePath)
{
global $currentPageIndex,$pageSize,$totalPage,$absoluteIndex,$totalRecord;
/*
echo $currentPageIndex.'<br/>';
echo $pageSize.'<br/>';
echo $totalPage.'<br/>';
echo $absoluteIndex.'<br/>';
echo $totalRecord.'<br/>';
*/
if(isset($_GET['pageIndex']))
{
$currentPageIndex = $_GET["pageIndex"];
if(empty($currentPageIndex) or $currentPageIndex < 0 or !is_numeric($currentPageIndex)){
$page = 1;
}else {
$currentPageIndex = intval($currentPageIndex);
}
}else{
$currentPageIndex = 1;
}
//判断可点击状态
if($currentPageIndex >= $totalPage)
{
//说明,到了最后一页:下一页,末页不可点击
$currentPageIndex = $totalPage;
echo "<div style='margin:0 auto; width:400px; height:25px; border:0px solid #F00'>$currentPageIndex/$totalPage | 共有".$totalPage."条 | <a href='$pagePath". "?pageIndex=1"."'>首页</a> | <a href='$pagePath"."?pageIndex=".($currentPageIndex - 1)."'>上一页</a> | <a>下-页</a> | <a>末页</a></div>";
}elseif($currentPageIndex <= 1)
{
//说明,到了首页:上一页,首页不可点击
$currentPageIndex = 1;
echo "<div style='margin:0 auto; width:400px; height:25px; border:0px solid #F00'>$currentPageIndex/$totalPage | 共有".$totalPage."条 | <a>首页</a> | <a>上一页</a> | <a href='$pagePath"."?pageIndex=".($currentPageIndex + 1)."'>下-页</a> | <a href='$pagePath"."?pageIndex=$totalPage"."'>末页</a></div>";
}else{
echo "错误";
}
//echo "<div style='margin:0 auto; width:400px; height:25px; border:0px solid #F00'>$currentPageIndex/$totalPage | 共有12页 | <a href='$pagePath". "?pageIndex=1"."'>首页</a> | <a href='$pagePath"."?pageIndex=".($currentPageIndex - 1)."'>上一页</a> | <a href='$pagePath"."?pageIndex=".($currentPageIndex + 1)."'>下-页</a> | <a href='$pagePath"."?pageIndex=$totalPage"."'>末页</a></div>";
}