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
投稿

猜你喜欢

  • 详解用python -m http.server搭一个简易的本地局域网

    2023-09-29 13:03:34
  • js中判断数字\\字母\\中文的正则表达式 (实例)

    2024-04-10 10:56:07
  • python 实现超级玛丽游戏

    2023-10-10 09:38:38
  • Qt数据库应用之实现通用数据生成器

    2024-01-16 00:37:49
  • php+html5基于websocket实现聊天室的方法

    2023-11-15 06:58:58
  • Python3 文章标题关键字提取的例子

    2022-02-08 03:45:32
  • MySQL 开启慢查询日志的方法

    2024-01-20 13:41:05
  • python编译pyc文件的过程解析

    2022-08-13 20:48:19
  • 使用Visual Studio 2022开发前端的详细教程

    2023-07-02 05:30:35
  • python时间序列按频率生成日期的方法

    2021-10-04 22:38:40
  • MySQL 字符串模式匹配 扩展正则表达式模式匹配

    2024-01-20 14:47:41
  • JS简单模拟触发按钮点击功能的方法

    2024-04-22 13:02:52
  • vue 全局引用公共的组件以及公共的JS文件问题

    2024-05-29 22:44:46
  • 用python爬取租房网站信息的代码

    2022-04-30 07:03:38
  • python爬虫headers设置后无效的解决方法

    2021-09-04 00:55:17
  • Python数组定义方法

    2021-05-30 08:46:39
  • 从生成CRD到编写自定义控制器教程示例

    2024-05-05 09:30:37
  • python pygame入门教程

    2023-10-08 11:32:15
  • mysql 8.0.15 winx64解压版安装配置方法图文教程

    2024-01-26 07:11:18
  • Python抓新型冠状病毒肺炎疫情数据并绘制全国疫情分布的代码实例

    2022-10-11 23:14:40
  • asp之家 网络编程 m.aspxhome.com