ss.asp如下:
<!--#include file="function.asp"-->
<form id="form1" name="form1" method="post" action="ss.asp">
请输入查询关键字:
<input type="text" name="a1" />
<input type="submit" name="Submit" value="提交" />
</form>
<table width="200" border="1">
<%
Dim db,ConnStr1
ConnStr1="Dbq="&Server.Mappath("admin.mdb")&";Driver={Microsoft Access Driver (*.mdb)}"
Set db=Server.CreateObject("ADODB.Connection")
db.Open ConnStr1
a1=request("a1")
set rsa1=server.CreateObject("adodb.recordset")
ccce1="select * from wz where title like '%"&trim(a1)&"%'"
rsa1.open ccce1,db,1
if not rsa1.bof and not rsa1.eof then
dim page_size
dim page_no
dim page_total
page_size=5
if request("page_no")="" then
page_no=1
else
page_no=cint(request("page_no"))
end if
session("page_no")=page_no
rsa1.pagesize=page_size
page_total=rsa1.pageCount
rsa1.absolutepage=page_no
dim I,J
i=0
j=page_size
do while not rsa1.eof and j>0
I=I+1
J=J-1
%>
<tr>
<td><%=rsa1("title")%></td>
</tr>
<%
rsa1.movenext
loop
end if
%>
</table>
<% call select_page(page_no,page_total,a1) %>
function.asp如下
<%
private sub select_page(page_no,total_page,a1)
Dim I
i=1
response.write "文章数量:"&eee&"  "
if page_no=1 then
response.write "首页 "
else
response.write "<a href='ss.asp?page_no=" & I & "&a1="&a1&"'>首页</a> "
end if
If page_no<>1 then
response.write "<a href='ss.asp?page_no="& (Page_no-1) &"&a1="&a1&"'>上一页</a> "
else
response.write "上一页 "
end if
If Page_no <> total_page Then
response.write "<a href='ss.asp?page_no="& (Page_no+1) &"&a1="&a1&"'>下一页</a> "
else
response.write "下一页 "
end if
if page_no=total_page then
response.write "尾页 "
else
response.write "<a href='ss.asp?page_no=" & total_page & "&a1="&a1&"'>尾页</a>"
end if
response.write " 页次:"&page_no&"/"&page_total&" 每页"&r&" "
End sub
%>
[原创]asp查询分页显示