栏目导航
热点推荐
- ASP下批量删除数据的两种方法
- 关于二级域名共享cookies
- ASP错误代码大全
- ASP代码实现show.asp?id=26变成s
- ASP错误信息解决:IIS启用父路径
- 一些常用的正则表达式大全
- ASP超级链接和HTML函数正则表达
- ASP隐藏下载地址及防盗代码
- 最常用的正则表达式示例
- ASP程序数据库被挂马的处理方法
- ASP生成html的新方法
- 精通ASP错误提示大全
阅览排行
ASP写的不错的"数字分页"涵数
www.jz123.cn 2008-10-04 来源: 中国建站 编辑整理 我要投递新闻
'============================================================
' ********************数字分页涵数********APJE.2008-10-01
'SQL: 查询语句
'PageSizeN: 每页显示多少新闻记录
'classid: 栏目ID
'PageCountS: 总页数
'thispage: 当前页码
'StarP: 开始页码
'EndP: 结束页码
'ShowPage: 每页显示多少个数字页码
'vvv: 循环体的各个页码
'RecordCountS: 记录集的总记录数
'============================================================
Function PageStr(SQL,PageSizeN,classid,thispage)
dim RecordCountS,PageCountS,ShowPage,StarP,EndP,i,upPage,NextPage,sqlstr,thispage,vvv,BasePage
Set Rs = Server.CreateObject("adodb.Recordset")
Rs.open SQL,conn,1,1
RecordCountS = rs.recordcount
if RecordCountS <> 0 Then
ShowPage = 10
PageCountS = Int(RecordCountS/PageSizeN)
IF (RecordCountS Mod PageSizeN) > 0 Then
PageCountS = PageCountS+1
end if
If thispage > PageCountS Then thispage = PageCountS
vvv = thispage
StarP = ThisPage-(ShowPage/2)+1
IF StarP < 1 Then
StarP = 1
end if
EndP = ThisPage+(ShowPage/2)
IF EndP > PageCountS Then
EndP = PageCountS
end if
'****************循环输出页码
BasePage = (thispage \ showpage) * showpage
if thispage mod showpage = 0 then basepage = ( basepage \ showpage ) * showpage - showpage
For i = 1 to showpage
Dim Showstr
vvv = BasePage + i
if vvv > PageCountS Then exit for
if vvv = thispage then
Showstr = Showstr & "[" & vvv & "]"
else
Showstr = Showstr & "<a href='?type=list&classid=" & classid & "&page=" & vvv & "'>[" & vvv & "]</a>"
End If
Next
'***************开始部分
upPage = ThisPage - 1
If ThisPage < 2 Then
Showstr = "<span style='font-family:Webdings'>9</span> <span style='font-family:Webdings'>7</span> " & Showstr
Else
Showstr = "<a href='?type=list&classid="&classid&"&page=1' style='font-family:Webdings'>9</a> <a href='?type=list&classid="
& classid & "&page=" & upPage & "' style='font-family:Webdings'>7</a> " & Showstr
End If
'***************结束部分
NextPage = ThisPage + 1
If ThisPage >= PageCountS Then
Showstr = Showstr & " <span style='font-family:Webdings'>8</span> <span style='font-family:Webdings'>:</span>"
Else
Showstr = Showstr & " <a href='?type=list&classid=" & classid & "&page=" & NextPage & "' style='font-family:Webdings'>8</a>
<a href='?type=list&classid=" & classid & "&page=" & PageCountS & "' style='font-family:Webdings'>:</a>"
End If
rs.Close
Set rs = Nothing
PageStr = Showstr
else
rs.Close
Set rs = Nothing
end if
End Function
上一篇:ASP无须系统组件实现伪静态 下一篇:ASP编程代码:隐藏图片的真实地址