搜索结果不能分页,请各位帮手。
可以将搜索结果显示出来,上一页、下一页显示不对。请各位帮手看一下。谢谢!<%
dim page,i,m,total
key=request("keywords")
set rs =server.CreateObject("adodb.recordset")
sql = "select * from products where CnProModel & CnProName like '%"&key&"%' order by ID desc"
rs.open sql,conn,1,2
if rs.eof and rs.bof then
response.Write "<script>alert('没有找到相应的记录!')</script>"
else
page = request.QueryString("page")
rs.pagesize = 5
total = rs.recordcount
if Not IsEmpty(trim(request("page"))) then
page = CInt(request("page"))
if page > rs.pagecount then
rs.absolutepage = rs.pagecount
elseif page <= 0 then
page =1
else
rs.absolutepage=page
end if
end if
page=rs.absolutepage
for j=1 to rs.PageSize
%>
<table>
<tr>
<td><%=rs.Fields("CnProName")%></td>
</tr>
</table>
<%
rs.movenext
if rs.eof then exit for
next
%>
<%if page<2 then%>
首页 上一页
<%else%>
<a href="doquery.asp?page=1&key=<%=key%>">首页</a>|
<%end if%>
<%if page > 1 then%>
<a href="doquery.asp?page=<%=page - 1%>&key=<%=key%>">上一页</a>|
<%end if%>
<%if page < rs.pagecount then%>
<a href="doquery.asp?page=<%=page + 1%>&key=<%=key%>">下一页</a>|
<%end if%>
<a href="doquery.asp?page=<%=rs.pagecount%>&key=<%=key%>">尾页</a>|
<%
end if
rs.close
set rs=nothing
%>