<%
'******************************
'函數:MultiPage(Numbers,Perpage,Curpage,Url_Add)
'參數:Numbers,總記錄數;Perpage,每頁記錄數;Curpage,當前頁;Url_Add,當前頁其它參數如?action=list&
'作者:阿裡西西
'日期:2007/7/15
'描述:ASP通用分頁樣式函數
'示例:MultiPage(100,10,2,"?action=list&")
'******************************
Function MultiPage(Numbers,Perpage,Curpage,Url_Add)
CurPage=Int(Curpage)
Dim URL
URL=Request.ServerVariables("Script_Name")&Url_Add
MultiPage=""
Dim Page,Offset,PageI
If Int(Numbers)>Int(PerPage) Then
Page=10
Offset=2
Dim Pages,FromPage,ToPage
If Numbers Mod Cint(Perpage)=0 Then
Pages=Int(Numbers/Perpage)
Else
Pages=Int(Numbers/Perpage)+1
End If
FromPage=Curpage-Offset
ToPage=Curpage+Page-Offset-1
If Page>Pages Then
FromPage=1
ToPage=Pages
Else
If FromPage<1 Then
Topage=Curpage+1-FromPage
FromPage=1
If (ToPage-FromPage)<Page And (ToPage-FromPage)<Pages Then ToPage=Page
ElseIF Topage>Pages Then
FromPage =Curpage-Pages +ToPage
ToPage=Pages
If (ToPage-FromPage)<Page And (ToPage-FromPage)<Pages Then FromPage=Pages-Page+1
End If
End If
MultiPage="<a href='"&Url&"page=1'><<</a> "
For PageI=FromPage TO ToPage
If PageI<>CurPage Then
MultiPage=MultiPage&"<a href='"&Url&"page="&PageI&"'>["&PageI&"]</a> "
Else
MultiPage=MultiPage&"<b>["&PageI&"]</b> "
End If
Next
If Int(Pages)>Int(Page) Then
MultiPage=MultiPage&" ... <a href='"&Url&"page="&Pages&"'> ["&pages&"] >></a>"
Else
MultiPage=MultiPage&"<a href='"&Url&"page="&Pages&"'>>></a>"
End If
End If
End Function%>