分页代码:
<%
sql="select * from test "
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if not rs.eof then
rs.PageSize=5
pagecount=rs.PageCount
page=int(request.QueryString ("page"))
if page<=0 then page=1
if request.QueryString("page")="" then
page=1
end if
rs.AbsolutePage=page
end if
%>
<table width="748" border="1" cellspacing="0" cellpadding="0">
<%for i=1 to rs.PageSize%>
<%if rs.EOF then
exit for
end if
%>
<tr>
<td><a href="del.asp?id=<%=rs("id")%>">del</a></td>
<td><a href="modify.asp?id=<%=rs("id")%>" target="_self"><%=rs("aa")%></a></td>
<td><%=rs("bb")%></td>
</tr>
<%rs.movenext
next
%>
<!--循环体结束
分页部分:-->
<table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<tr>
<%if rs.pagecount > 0 then%>
<td width="13%" align="left">当前页<%=page%>/<%=rs.PageCount%></td>
<%else%>
<td width="41%" align="left">当前页0/0</td><%end if%>
<td width="46%" align="right"> <a href="new1.asp?page=1">首页</a>|
<%if page >1 then%>
<a href="new1.asp?page=<%=page -1%>">上页</a>| <%end if%>
<%if page<pagecount then%>
<a href="new1.asp?page=<%=page +1%>">下页</a> |<%end if%>
<a href="new1.asp?page=<%=rs.PageCount%>">尾页</a>|转到第
<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
<%
for i = 1 to rs.PageCount
if i = page then%>
<option value="new1.asp?page=<%=i%>" selected><%=i%></option>
<%else%>
<option value="new1.asp?page=<%=i%>"><%=i%></option>
<%
end if
next
%>
</select>页</font>
</td>
</tr>
</table>