ASP写的不错的"数字分页"涵数
作者:APJE 时间:2008-10-19 17:21:00
asp数字分页涵数
参数说明:
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
0
投稿
猜你喜欢
asp长文章分页显示思路
2007-08-23 13:54:00
Persits AspJpeg组件图片水印\\缩略图\\图片合并\\图片切割\\实例教程
2008-12-14 10:36:00
css学习笔记: css新闻列表的特殊做法
2009-07-19 14:25:00
YUI 学习笔记:Event
2009-02-21 11:15:00
asp操作Excel类源码
2009-12-25 19:01:00
如何编写高质量的Javascript代码
2011-03-07 16:04:00
JS获取对象代码总结
2011-03-07 16:14:00
SQL Server如何才能访问Sybase中的表
2009-01-08 13:33:00
有关JS中Event对象的几点总结
2009-03-06 12:36:00
asp组件上传
2010-05-27 12:16:00
教你快速掌握SQL语言中游标的使用技巧
2009-01-08 16:24:00
js金额浮点格式化控件
2008-08-01 16:52:00
安装Oracle加载数据库错误areasQueries的解决
2010-07-27 13:02:00
asp如何在聊天室实现趣味答题并计分功能?
2010-06-18 20:00:00
解析:安装 MySQL时如何选择安装软件包
2008-12-31 17:15:00
ASP长文章分页代码实例
2007-10-02 17:04:00
ASP 自动采集实现代码
2011-03-07 11:17:00
渗透和改变 非洲web 2.0网站Logo
2008-01-22 13:31:00
Python处理mysql数据库
2010-12-03 16:23:00
解析:Perl下应当如何连接Access数据库
2008-11-28 16:40:00