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