<!--
===================== 分页函数[2005.05.13] Create By zhisi.net ==================
        五个参数：
  		T_rsnum		= 	rs.RecordCount      总记录数
		E_pagersnum = 	2                   每页纪录数
		N_page		=	Now Page Number		当前页数
		U_linkto	=	"page.asp?"			URL
		sDescribe	=	"留言/记录"			描述记录

       @ 代码段 1 —— 获取当前页数和记录定位

  		N_page = Trim(Request("pn"))
  		if N_page="" then
    		N_page=1
    		rs.movefirst
  		else
    		rs.move Clng(N_page-1)*E_pagersnum
  		end if
		
	   @ 代码段 2 —— 用于判断记录位置
	   
 		i=0
 		while i<E_pagersnum and not rs.eof 
		
	   调用示例：
	   Call DiPage(T_rsnum, E_pagersnum, N_page, "saylistt.asp?", "条言论")

-->
<%
Sub GetPageNo()

End Sub
%>
<%	
Function DiPage(T_rsnum, E_pagersnum, N_page, U_linkto, sDescribe)
	T_pagenum 	= 	T_rsnum-1    
	T_pagenum 	= 	Int(T_pagenum/E_pagersnum) + 1         '总页数
	sNavig 		=	"共有&nbsp;<b>" & T_rsnum & "</b>&nbsp;" & sDescribe
	sNavig		=	sNavig + "，共&nbsp;<b>" & T_pagenum & "</b>&nbsp;页，"
	sNavig		=	sNavig + "这是第&nbsp;<b>" & N_page & "</b>&nbsp;页。"
	
	If Clng(N_page)>1 Then
		sNavigP =   "<a href=" & U_linkto & "pn=1>" & "首页</a> | "
		sNavigP =   sNavigP + "<a href=" & U_linkto & "pn=" & Clng(N_page)-1 & ">上一页</a> | "
	Else 
	    sNavigP =   "首页 | 上一页 | "
	End If
	
	If Clng(N_page)<T_pagenum Then
		sNavigN =	"<a href=" & U_linkto & "pn=" & Clng(N_page)+1 & ">下一页</a> | "
		sNavigN =   sNavigN + "<a href=" & U_linkto & "pn=" & T_pagenum & ">尾页</a>"
	Else
		sNavigN =	"下一页 | 尾页"
	End If
	
	sNavig 	=	"<div class=dipage><li>" + sNavig + sNavigP +sNavigN + "</li></div><div class=dipage><li>"
	Response.Write(sNavig)
	
	'页码显示以块为单位，每次显示一块，每块页面数确定
	'显示页码数量（如：为 5时显示 5个页码：1 2 3 4 5）
	Dim iPageBlockSum
	'默认显示 5个页码
	iPageBlockSum = 10
	'当前的页面块计数
	Dim iCurrPageBlockNum
	'页面块初始值为1
	iCurrPageBlockNum = ( ( N_page - 1 ) \ iPageBlockSum ) + 1
	
	Dim iPageBlockCount
	
	iPageBlockCount = ( T_pagenum \ iPageBlockSum ) + 1
	
	'如果当前页面大于页面长度，则显示前pageSum页（比如：前5页）
	If iCurrPageBlockNum > 1 Then
		Response.Write("<a href="&U_linkto&"pn="&(iCurrPageBlockNum-1)*iPageBlockSum&"><b>前"&iPageBlockSum&"页</b></a>&nbsp;&nbsp;")
	Else
		Response.Write("<b>前"&iPageBlockSum&"页</b>&nbsp;&nbsp;")
	End If

	i = (iCurrPageBlockNum-1) * iPageBlockSum + 1
	j = i + iPageBlockSum
	While i < j And i<= T_pagenum
		Response.Write "<a href=" & U_linkto & "pn=" & i & ">" & i &"</a> " 
		i=i+1 
	Wend
	
	If iCurrPageBlockNum < iPageBlockCount Then
		Response.Write("&nbsp;&nbsp;<a href="&U_linkto&"pn="& iCurrPageBlockNum * iPageBlockSum + 1 &"><b>后"&iPageBlockSum&"页</b></a>")
	Else
		Response.Write("&nbsp;&nbsp;<b>后"&iPageBlockSum&"页</b>")
	End If
	
	Response.Write("</li></div>")

End Function
%>  

