<?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>";
}
/**
* 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>";
}
解决方案 »
- 哪位大侠能够一条sql语句执行更新多条记录
- PHP 展开与收缩
- 谁知道php 写webservice服务器端?
- 请问下关于PHP如何对文件夹做访问权限
- 记录访问页面的入口数问题,在线等
- COM("Excel.application")不执行不出错?请教~
- php读取文件,包含了中文就出现乱码
- 有用过mb_convert_encoding函数的吗?我将utf-8转换为gbk的时候,空格变成了???
- 请问怎样才能关联两个表在显示记录的同时显示图片?
- [灌水]郁闷,每次看到“宇凡”请进都以为是在叫我~~
- tp3.2.3自动成功后自动跳转,后面什么代码都没写,页面自己跳转
- setFiled 方法第二个参数是变量要怎么写SQL?
echo "错误";
}
//echo "
改为
}else//{
// echo "错误";
// }
echo "