分页函数及最佳统计记录方法
2006-12-22 02:54
387 查看
<?
if(!function_exists(pageft)){
function pageft($totle,$displaypg=20,$url=''){
global $page,$firstcount,$pagenav,$_SERVER;
$GLOBALS["displaypg"]=$displaypg;
if(!$page) $page=1;
if(!$url){ $url=$_SERVER["REQUEST_URI"];}
$parse_url=parse_url($url);
$url_query=$parse_url["query"];
if($url_query){
$url_query=ereg_replace("(^|&)page=$page","",$url_query);
$url=str_replace($parse_url["query"],$url_query,$url);
if($url_query) $url.="&page"; else $url.="page";
}else {
$url.="?page";
}
$lastpg=ceil($totle/$displaypg);
$page=min($lastpg,$page);
$prepg=$page-1;
$nextpg=($page==$lastpg ? 0 : $page+1);
$firstcount=($page-1)*$displaypg;
$pagenav="";
if($lastpg<=1) return false;
if($page!=1) $pagenav.=" <a href='$url=1'> <img src="".WWW.BACK."images/first.jpg" width="64" height="16" border="0"></a> "; else $pagenav.=" <img src="".WWW.BACK."images/first.gif" width="64" height="16" border="0"> ";
if($prepg) $pagenav.="<a href='$url=$prepg'><img src="".WWW.BACK."images/previous.jpg" width="81" height="16" border="0"></a> "; else $pagenav.="<img src="".WWW.BACK."images/previous.gif" width="81" height="16"> ";
if($nextpg) $pagenav.="<a href='$url=$nextpg'><img src="".WWW.BACK."images/next.jpg" width="81" height="16" border="0"></a>"; else $pagenav.="<img src="".WWW.BACK."images/next.gif" width="81" height="16">";
if($page!=$lastpg) $pagenav.=" <a href='$url=$lastpg'><img src="".WWW.BACK."images/last.jpg" width="64" height="16" border="0"></a>"; else $pagenav.=" <img src="".WWW.BACK."images/last.gif" width="64" height="16" border="0">";
$pagenav.=" Goto<select name='topage' style='font-size:9px' size='1' onchange='window.location="$url="+this.value'> ";
for($i=1;$i<=$lastpg;$i++){
if($i==$page) $pagenav.="<option value='$i' selected>$i</option> ";
else $pagenav.="<option value='$i'>$i</option> ";
}
$pagenav.="</select> 共:$lastpg 页$totle 条记录";
}
}
?>
调用
$temp = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM product where delfag=0 $where LIMIT 1");
$result = mysql_query("SELECT FOUND_ROWS()");
$total = mysql_fetch_row($result);
pageft($total,25,$pageSelf);
相关文章推荐
- 记录一下PHP数组数据分页的方法 array_slice() 函数的使用
- oracle中LAG()和LEAD()等分析统计函数的使用方法(统计月增长率)
- R--基本统计分析方法(包及函数)
- hibernate 多表联合查询,分页,重复记录导致的总记录数不对的解决方法。
- Mybatis分页-利用Mybatis Generator插件生成基于数据库方言的分页语句,统计记录总数
- 记录: Sql 常见分页方法总结
- 记录一下PHP数组数据分页的方法
- mysql 分页存储过程 一次返回两个记录集(行的条数,以及行记录),DataReader的Read方法和NextResult方法
- 第二种:自定义类MyThread 实现Runnable接口,主函数创建5个线程,自定义线程类的构造函数输出 创建线程X * run方法内统计每个线程 一共6次
- error C2470 错误记录与解决方法。“看起来像函数定义,但没有参数列表”
- SQL中分组函数的使用及前N条记录的查询方法
- DataTable中数据记录的排序,检索,合并,分页,统计
- JavaScript学习记录day6-函数变量作用域、解构赋值与方法
- Linux下的函数执行时间的统计方法
- [MySQL] 行列转换变化各种方法实现总结(行变列报表统计、列变行数据记录统计等)
- 取得查询的记录总数分页显示用的方法
- PHP长文章分页函数,带使用方法,不会分割段落,翻页在底部
- Delphi:记录类型、过程指针、函数(方法)指针字段的应用
- PHP 长文章分页函数 带使用方法,不会分割段落,翻页在底部
- PHP 长文章分页函数 带使用方法,不会分割段落,翻页在底部