求助asp分页出错,急

王朝知道·作者佚名  2009-12-11
窄屏简体版  字體: |||超大  
 
分類: 電腦/網絡 >> 程序設計 >> 其他編程語言
 
問題描述:

以下代码,搜索结果出来后第一页是正确显示的,点击下一页后就会显示所有的数据库记录了。请高手帮看看是哪里出了问题?

<%

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")

小贴士:① 若网友所发内容与教科书相悖,请以教科书为准;② 若网友所发内容与科学常识、官方权威机构相悖,请以后者为准;③ 若网友所发内容不正确或者违背公序良俗,右下举报/纠错。
 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航