<%@language="vbscript" codepage=""%>
<%
定义数据连接
option explicit
on error resume next
dim startimeendtime
startime=timer()
dim dbconnrs
db = "provider=microsoftjetoledb;data source=" & servermappath("/dbmdb")
set conn = servercreateobject("adodbconnection")
set rs = servercreateobject("adodbrecordset")
connopen db
%>
<%
**************
分页导航栏函数
输出wzpage值
**************
Function pagination(pagecount)
Dim wzpagewzpagecountpagenumboardid
boardid = RequestQueryString("board_id")
If boardid = Then boardid =
If Len(RequestQueryString("page"))<> Then
wzpage = clng(RequestQueryString("page"))
Else
wzpage =
End If
If wzpage <= Then wzpage =
pagenum = (wzpage )*+
If wzpage mod = Then pagenum = (wzpage )*
If wzpage > Then
ResponseWrite ("<font face=""webdings"">")
ResponseWrite ("<a href=""?board_id="& boardid &"&page="" title=""首页""></a>")
ResponseWrite ("<a href=""?board_id="& boardid &"&page="& pagenum &""" title=""前十页""></a>")
ResponseWrite ("</font>")
End If
For pagenum = pagenum To pagenum +
If pagenum = wzpage Then
ResponseWrite ("<font color=""#ff"">")
ResponseWrite (" ["& pagenum &"] ")
ResponseWrite ("</font>")
Else
ResponseWrite (" <a href=""?board_id="& boardid &"&page="& pagenum &""">")
ResponseWrite ("["& pagenum &"]")
ResponseWrite ("</a> ")
End If
If pagenum >= pagecount Then Exit For
Next
If wzpage < (pagecount (pagecount )) Then
ResponseWrite ("<font face=""webdings"">")
ResponseWrite ("<a href=""?board_id="& boardid &"&page="& pagenum &""" title=""后十页""></a>")
ResponseWrite ("<a href=""?board_id="& boardid &"&page="& pagecount &""" title=""末页"">:</a>")
ResponseWrite ("</font>")
End If
End Function
%>
<%
dim rssqlgetstring
getstring = clng(requestquerystring("board_id"))
if getstring = then getstring =
******************************************
取文章总数及每页重复显示条数准备分页
wzcount 文章总数
wzrep 重复显示条数
wzpage 分页参数id
wzpagecount 总页数
******************************************
dim wzcountwzrepwzpagewzpagecountwzpagerepboardstr
wzrep =
rssql = "select count(id) from `table`"
rsopen rssqlconn&h
wzcount = connexecute ("select count(id) from `table`")()
rsclose
wzpagecount = abs(int(abs(wzcount/wzrep)))
wzpage = clng(requestquerystring("page"))
if len(wzpage) = or wzpage = then wzpage =
%>
<html>
<head>
<title>分页测试</title>
<meta httpequiv="contenttype" content="text/html; charset=gb">
<link rel="stylesheet" href="pagecss" type="text/css">
</head>
<body>
<table width="" border="" cellspacing="" cellpadding="" align="center" bordercolordark="#ffffff" bordercolorlight="#cccccc">
<tr align="center">
<td width="">ID</td>
<td width="">标题</td>
<td width="*">内容(显示前个字)</td>
<td width="">时间</td>
</tr>
<%
取文章列表
rssql = "select idaaaabbbbcccc from `table` order by id desc"
rsopen rssqlconn&h
根据分页参数获取当前页面纪录
rsabsoluteposition=rsabsoluteposition+((abs(wzpage))*wzrep)
显示文章标题列表
if rseof or rsbof then%>
<tr>
<td >暂无记录</td>
</tr>
<% else
dim ibgcolor
for i = to wzrep
if rseof then exit for
while not rseof and i <= wzrep
bgColor="#FFFFFF"
if i mod = then bgColor="#DFEFFF"
%>
<tr bgcolor="<%=bgColor%>">
<td width=""><%=rs()%></td>
<td width=""><%=rs()%></td>
<td width="*"><%=left(rs())%></td>
<td width=""><%=rs()%></td>
</tr>
<%
rsmovenext
i=i+
wend
next
end if
%>
</table>
<table width="" border="" cellspacing="" cellpadding="" align="center">
<tr>
<td align="left" width="">共<font color=red><%= wzcount%></font>条 <font color=red><%= wzrep%></font>/页 共<font color=red><%= wzpagecount%></font>页</td>
<td align="right"> <%= pagination(wzpagecount)%></td>
</tr>
</table>
<table width="" border="" align="center" cellpadding="" cellspacing="">
<tr>
<td align="center">
<%endtime=timer()%>
本页面执行时间<%=formatnumber((endtimestartime)*)%>毫秒</td>
</tr>
</table>
</body>
</html>
<%
释放资源
rsclose
set rs = nothing
connclose
set conn = nothing
%>