php分页函数
<?php
function page ( $totalPage , $currentPage,$url ,$halfPer=5)
{
$total=$totalPage-1;
$re="<td><a href="\" mce_href="\""$url\" onclick=\"page=prompt('共{$totalPage}页\\n自定义跳转到第几页:','');if(page>0&&page<$total)location.href=this.href+'='+(page-1);return false\">跳转</a></td>\n";
$re .= ( $currentPage > 0 )
? "<td><a href="\" mce_href="\""$url=0\">首页</a></td>\n<td><a href="\" mce_href="\""$url=".($currentPage-1)."\">上一页</a></td>\n"
: "<td>首页</td>\n<td>上一页</td>\n";
for ( $i = $currentPage - $halfPer,$i > 0 || $i = 0 , $j = $currentPage + $halfPer, $j < $totalPage || $j = $totalPage;$i < $j ;$i++ )
{
$re .= $i == $currentPage
? "<td><b class=currentPage>[" . ( $i + 1 ) . "]</b></td>\n"
: "<td><a href="\" mce_href="\""$url=$i\">" . ( $i + 1 ) . "</a></td>\n";
}
$re .= ( $currentPage < $total )
? "<td><a href="\" mce_href="\""$url=" . ( $currentPage + 1 ) . "\">下一页</a></td>\n<td><a href="\" mce_href="\""$url=" . ( $total )."\">尾页</a>\n</td>"
: "<td>下一页</td>\n<td>尾页</td>\n";
$re="<table style="text-align:center" mce_style="text-align:center"><tr>$re</tr></table>";
return $re;
}
?>
具体示例用法如下:
<?php
$totalPage = 100 ; //总分页数量
$currentPage = @$_GET['page']+0; //当前页码
$url = "?page"; //分而链接
$halfPer = 10; //二分之一的每页的信息数
$imagePath ="images"; //分页图片目录
$pageHtml = page ( $totalPage , $currentPage,$url ,$halfPer,$imagePath);//调用分页函数
echo $pageHtml ;
?&
相关文档:
PHP 序列化(serialize)格式详解
前言
概述
NULL 和标量类型的序列化
简单复合类型的序列化
嵌套复合类型的序列化
自定义对象序列化
Unicode 字符串的序列化
参考文献
1.前言
PHP (从 PHP 3.05 开始)为保存对象提供了一组序列化和反序列化的函数:serialize、unserialize。不过在
PHP 手册中对这两个函数的 ......
PHP中设计模式的学习笔记
设计模式(Design Pattern)是面向对象设计中反复出现的问题的解决方案,设计模式是一种比一般类的设计更加抽象的一种思想,
它往往涉及到多个类的定义和使用。
在PHP的开发过程中,经常使用到得设计模式包括:简单工厂模式、单元素模式、观察者模式、命令模式、策略模式以及MVC模式等。
/ ......
今天2010-02-26,开始我的php学习之路,
计划在未来的一段时间内,用足够多的时间和精力来学习了解php。
做到精通理解还有就是自己独立的开发出一系列的网站,作为对自己学习的检验。
做好技术总结和技术内核理解 ......