/*====对数据的记录进行分页显示=====;;
一张页面有连续的十个页面的连接;;
一页可显示$limit_row条记录信息;;
并有下十页和上十页翻页功能;;
===================================;;
------需传入值$total_row;$limit_row;$pagename;-----;;
$total_row为所选查询结果的总行数;;
$limit_row为每页显示的最大行数;;
$pagename为返回显示页面名称。(不带后缀名);;
----------------------------------------------------;;
----------------------------------------------------;;
$page当前所读页面;;
$total_page为共可分为几页.;;
$row_begin为从第几行开始读;;
$row_end为读到第几行为止;;
-----------------------------------------------------*/;;
if (!$page){ $page=1;};;
$total_page=ceil($total_row/$limit_row);;;
$row_begin=$limit_row*($page-1);;;
if($page==$total_page&&($total_row%$limit_row)){;;
$read_row=($total_row%$limit_row);;;
}else{$read_row=$limit_row;};;
if($total_page<=10){;;
$page_begin=0;;;
$page_end=$total_page;;;
$page10=1;;;
$newpage10=1;;;
}else{;;
//--------------分页显示下十页----------------;;
// $page10为总共有几个十页;;
// $newpage10为读十页的起始位置;;
// $page_endx为读取最后的页数;;
$page10=ceil($total_page/10);;;
if($newpage10 ==""){$newpage10=1;};;
$page_begin=10*($newpage10-1);;;
if($newpage10==1);;
{;;
if($newpage10==($page10-1)&&($total_page%10));;
{;;
$page_endx=$total_page%10;;;
$page_end=10;;;
echo "<FONT FACE=ARIAL SIZE=2>| 最前十页 | <A HREF="$pagename.php?newpage10=2&&page=11">下 $page_endx 页</A> |</FONT>";;;
}else{;;
$page_end=10;;;
echo "<FONT FACE=ARIAL SIZE=2>| 已是最前十页 | <A HREF="$pagename.php?newpage10=2&&page=11">下十页</A> |</FONT>";;;
};;
}elseif($newpage10>1){;;
if($newpage10==$page10&&($total_page%10));;
{$page_end=$total_page%10;;;
echo "<FONT FACE=ARIAL SIZE=2>| <A HREF="$pagename.php?newpage10=".($newpage10-1)."&&page=".(($newpage10-2)*10+1)."">前十页</A> |已是最后 $page_end 页|</FONT>";;;
}else{;;
if($newpage10==($page10-1)&&($total_page%10));;
{ $page_endx=$total_page%10;;;
$page_end=10;;;
echo "<FONT FACE=ARIAL SIZE=2>|<a href="$pagename.php?newpage10=".($newpage10-1)."&&page=".(($newpage10-2)*10+1).""> 前十页</a> | <A HREF="$pagename.php?newpage10=".($newpage10+1)."&&page=".($newpage10*10+1)."">下 $page_endx 页</A> |</FONT>";;;
} else{;;
$page_end=10;;;
echo "<FONT FACE=ARIAL SIZE=2>| <A HREF="$pagename.php?newpage10=".($newpage10-1)."&&page=".(($newpage10-2)*10+1)."">前十页</A> | <A HREF="$pagename?newpage10=".($newpage10+1)."&&page=".($newpage10*10+1)."">下十页</A> |</FONT>";;;
};;
};;
};;
};;
//----------------------每十页页码--------------------------------------;;
echo "总共:".$total_row."条 第 ";;;
for ($n=$page_begin+1;$n<=$page_begin+$page_end;$n++){;;
echo "<a href=$pagename.php?newpage10=$newpage10&&page=$n >$n</a> ";;;
};;
echo "页";;;
?>
标签: