求助asp分页出错,急
以下代码,搜索结果出来后第一页是正确显示的,点击下一页后就会显示所有的数据库记录了。请高手帮看看是哪里出了问题?
<%
dim intPage,page,pre,last,filepath
mobile=request.form("mobile")
by_shenhe=request.form("by_shenhe")
money1=request.form("money1")
money2=request.form("money2")
set rs = server.CreateObject("adodb.recordset")
sql="select * from sell"
if len(mobile)<>0 then
if instr(sql,"where")<>0 then
if instr(sql,"and")<>0 then
sql=sql & " and mobile like '%"&trim(mobile)&"%'"
else
sql=sql & " and mobile like '%"&trim(mobile)&"%'"
end if
else
sql=sql &" where mobile like '%"&trim(mobile)&"%'"
end if
end if
if len(by_shenhe)<>0 then
if instr(sql,"where")<>0 then
if instr(sql,"and")<>0 then
sql=sql & " and by_shenhe like '%"&trim(by_shenhe)&"%'"
else
sql=sql & " and by_shenhe like '%"&trim(by_shenhe)&"%'"
end if
else
sql=sql &" where by_shenhe like '%"&trim(by_shenhe)&"%'"
end if
end if
if money1<>"" then
if instr(sql,"where")<>0 then
if instr(sql,"and")<>0 then
sql=sql & " and money>=" & money1
else
sql=sql & " and money>=" & money1
end if
else
sql=sql &" where money>=" & money1
end if
end if
if money2<>"" then
if instr(sql,"where")<>0 then
if instr(sql,"and")<>0 then
sql=sql & " and money<=" & money2
else
sql=sql & " and money<=" & money2
end if
else
sql=sql &" where money<=" & money2
end if
end if
rs.PageSize = 20
rs.CursorLocation = 3
rs.Open sql,conn,0,2,1
pre = true
last = true
page = trim(Request.QueryString("page"))
if len(page) = 0 then
intpage = 1
pre = false
else
if cint(page) =< 1 then
intpage = 1
pre = false
else
if cint(page) >= rs.PageCount then
intpage = rs.PageCount
last = false
else
intpage = cint(page)
end if
end if
end if
if not rs.eof then
rs.AbsolutePage = intpage
end if
%>
<%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then exit for
%>
这里是输出内容
<%
rs.movenext
next
%><table width="100%" border="0" cellpadding="0" cellspacing="1" borderColorLight=#808080 borderColorDark=#ffffff bgcolor="#E7F3FF">
<tr>
<%if rs.pagecount > 0 then%>
<td width="38%" align="left"><font color="#003063"> 每页显示20条记录</font> <font color="#003063">当前页<%=intpage%>/共<%=rs.PageCount%>页</font></td>
<%else%>
<td width="8%" align="left">当前页0/0</td><%end if%>
<td width="54%" align="right"> <a href="search.asp?page=1&mobile=<%=mobile%>&money2=<%=money2%>&money1=<%=money1%>&by_shenhe=<%=by_shenhe%>">首页</a>|
<%if pre then%>
<a href="search.asp?page=<%=intpage -1%>&mobile=<%=mobile%>&money2=<%=money2%>&money1=<%=money1%>&by_shenhe=<%=by_shenhe%>">上页</a>| <%end if%>
<%if last then%>
<a href="search.asp?page=<%=intpage +1%>&mobile=<%=mobile%>&money2=<%=money2%>&money1=<%=money1%>&by_shenhe=<%=by_shenhe%>">下页</a> |<%end if%>
<a href="search.asp?page=<%=rs.PageCount%>&mobile=<%=mobile%>&money2=<%=money2%>&money1=<%=money1%>&by_shenhe=<%=by_shenhe%>">尾页</a>
参考答案:把
mobile=request.form("mobile")
by_shenhe=request.form("by_shenhe")
money1=request.form("money1")
money2=request.form("money2")
改成
mobile=request("mobile")
by_shenhe=request("by_shenhe")
money1=request("money1")
money2=request("money2")