最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp 分页函数与数据库连接
时间:2022-07-02 23:10:15 编辑:袖梨 来源:一聚教程网
<%@language="vbscript" codepage="936"%>
<%
'定义数据连接
option explicit
on error resume next
dim startime,endtime
startime=timer()
dim db,conn,rs
db = "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("./db.mdb")
set conn = server.createobject("adodb.connection")
set rs = server.createobject("adodb.recordset")
conn.open db
%>
<%
'**************
'分页导航栏函数
'输出wzpage值
'**************
Function pagination(pagecount)
Dim wzpage,wzpagecount,pagenum,boardid
boardid = Request.QueryString("board_id")
If boardid = 0 Then boardid = 1
If Len(Request.QueryString("page"))<>0 Then
wzpage = clng(Request.QueryString("page"))
Else
wzpage =1
End If
If wzpage <= 0 Then wzpage =1
pagenum = (wzpage 10)*10+1
If wzpage mod 10 = 0 Then pagenum = (wzpage 10)*10-9
If wzpage > 10 Then
Response.Write ("")
Response.Write ("9")
Response.Write ("7")
Response.Write ("")
End If
For pagenum = pagenum To pagenum + 9
If pagenum = wzpage Then
Response.Write ("")
Response.Write (" ["& pagenum &"] ")
Response.Write ("")
Else
Response.Write (" ")
Response.Write ("["& pagenum &"]")
Response.Write (" ")
End If
If pagenum >= pagecount Then Exit For
Next
If wzpage < (pagecount - (pagecount 10)) Then
Response.Write ("")
Response.Write ("8")
Response.Write (":")
Response.Write ("")
End If
End Function
%>
<%
dim rssql,getstring
getstring = clng(request.querystring("board_id"))
if getstring = 0 then getstring = 1
'******************************************
'取文章总数及每页重复显示条数,准备分页
'wzcount 文章总数
'wzrep 重复显示条数
'wzpage 分页参数id
'wzpagecount 总页数
'******************************************
dim wzcount,wzrep,wzpage,wzpagecount,wzpagerep,boardstr
wzrep = 30
'rssql = "select count(id) from `table1`"
'rs.open rssql,conn,0,1,&h0001
wzcount = conn.execute ("select count(id) from `table1`",0,1)(0)
'rs.close
wzpagecount = abs(int(-abs(wzcount/wzrep)))
wzpage = clng(request.querystring("page"))
if len(wzpage) = 0 or wzpage = 0 then wzpage = 1
%>
css" type="text/css">
ID | 标题 | 内容(显示前20个字) | 时间 |
暂无记录 | |||
<%=rs(0)%> | <%=rs(1)%> | <%=left(rs(2),20)%> | <%=rs(3)%> |
共<%= wzcount%>条 <%= wzrep%>/页 共<%= wzpagecount%>页 | <%= pagination(wzpagecount)%> |
<%endtime=timer()%> 本页面执行时间:<%=formatnumber((endtime-startime)*1000,3)%>毫秒 |
<%
'释放资源
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22