标题:ASP读access数据库分页显示错误问题
取消只看楼主
cwang2100
Rank: 2
等 级:论坛游民
帖 子:12
专家分:12
注 册:2010-3-16
结帖率:100%
 问题点数:0 回复次数:0 
ASP读access数据库分页显示错误问题
我做的ASP网页是四个条件搜索,查找和显示网页都正常,但当点进入下一页后,显示的就不是原来所搜索出来的结果页数和内容了,而是变了全部数据库的重新分页和内容,不知是那里代码错了,我是菜鸟希望给我一完整一点的代码,谢谢!!

搜条如下图:



代码如下:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件</title>
</head>
<body bgcolor="#ffffff">

<table width=690 border="0" cellspacing="0" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" width="100%"  style="word-break:break-all" align="center">
<tr>
<td width="590" align="center" colspan="7">
<form method="POST" name="form1" action=sou.asp>
<P><font style="font-size: 14px " color="0000ff" align="left">搜索内容</font>
<input type="text" name="cxsj" size="15" id="cxsj"value="<%=request("cxsj")%>">
<select name="bb" id="bb">
<option selected="selected" value="">所在地区</option>
    <option value="广东"  <%if Request("bb")="广东" then Response.write "selected"%>>广东</option>
        <option value="江苏"  <%if Request("bb")="江苏" then Response.write "selected"%>>江苏</option>
        <option value="上海"  <%if Request("bb")="上海" then Response.write "selected"%>>上海</option>
    <option value="北京"  <%if Request("bb")="北京" then Response.write "selected"%>>北京</option>
</select>
    <select name="dd" id="dd">
    <option selected="selected" value="">等级分类</option>
    <option value="4"  <%if Request("dd")="4" then Response.write "selected"%>>一级</option>
        <option value="3"  <%if Request("dd")="3" then Response.write "selected"%>>二级</option>   
    <option value="2"  <%if Request("dd")="2" then Response.write "selected"%>>三级</option>   
      
</select>
        <select name="SearchUC" id="SearchUC">
    <option selected="selected" value="">默认排序</option>
    <option value="251" <%if Request("SearchUC")="251" then Response.write "selected"%>>按价格从低到高</option>
    <option value="99999991"  <%if Request("SearchUC")="99999991" then Response.write "selected"%>>信用度从高到低</option>
        <option value="250"   <%if Request("SearchUC")="250" then Response.write "selected"%>>按价格从高到低</option>
               
         
</select></select><input type="submit" value="搜索" name="B1"></form>  
</tr>
</table>

<TABLE width=690 bgColor=#FFFFFF border=0 bordercolor="0" align="center">
<TR>
<TD>

<%

cxsj=request.form("cxsj")
bb=request.form("bb")
dd=request.form("dd")
SearchUC=request.form("SearchUC")
dim pageCount
page = cint(request("page"))
set conn=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
conn.open "DBQ=" & server.mappath("/1/tao/SpiderResult.mdb") & ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"

sql="select * from Content where 1=1 "

Dim SearchStr

if cxsj <> "" then
sql=sql&"and minqing like '%"&cxsj& "%'"
end if
if bb<>"" then
sql=sql&"and dindi like '%"&bb&"%'"
end if

if dd<>"" then

sql=sql&"and guang like '%"&dd&"%'"

end if

if SearchUC="" then

sql=sql&"  order by id desc"

end if

if SearchUC="251" then

sql=sql&"  order by ping asc"

end if


if SearchUC="99999991" then
sql=sql&" order by guang desc"
end if


if SearchUC="250" then
sql=sql&" order by ping desc"

end if

rs.open sql,conn,3,3

if rs.bof then
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有该商品记录,请返回.
response.end
end if

RS.PageSize=8
pageCount = cint(rs.pageCount)

if page = 0 then
page =1
end if
RS.AbsolutePage = page
x=1

WHILE NOT RS.EOF AND NumRows<RS.PageSize
%>



<tr>
<td width="160"  >

<div align="center"><font  style="font-size: 13px">价格:</font><font style="font-size: 16px" color="#ff0000"><strong><%=rs("ping")%>元</strong></font></div>
</tr>
</td>
<tr>

</tr></div>
</table></div>



<%RS.MoveNext
NumRows=NumRows+1
WEND%>
<tr onmouseover="this.bgColor='#99ccff'" onmouseout="this.bgColor=''">
<td width="105%" align="center" colspan="6"> </td> </tr>
<tr>
<td width="105%" align="center" colspan="6">
<p align="center"><FONT color=#333333>共<%=PageCount%>页 第<%=page%>页★
<%if page=1 then%>首页<%end if%>
<%if page>1 then%>

<A HREF="sou.asp?page=1&cxsj=<%=request("cxsj")%>&bb=<%=request("bb")%>&dd=<%=request("dd")%>&SearchUC=<%=request("SearchUC")%>&"> 首页</A>
<%end if%>★
<%if page>1 then%><A HREF="sou.asp?page=<%=page-1%>&cxsj=<%=request("cxsj")%>&bb=<%=request("bb")%>&dd=<%=request("dd")%>&SearchUC=<%=request("SearchUC")%>&"><%end if%>上一页</a>
<%
dim pagewhere
dim p
p = 1
pagewhere = cint(request("pagewhere"))
pagewhere = pageCount
if pagewhere>0 then
for p=1 to pagewhere
if p <> page then%>
<A HREF="sou.asp?page=<%=p%>&cxsj=<%=request("cxsj")%>&bb=<%=request("bb")%>&dd=<%=request("dd")%>&SearchUC=<%=request("SearchUC")%>&"><%=p%></a>
<%end if
if p =page then%>
<%=p%>
<% end if
next
end if%>
<%if page < PageCount then%>
<A HREF="sou.asp?page=<%=page+1%>&cxsj=<%=request("cxsj")%>&bb=<%=request("bb")%>&dd=<%=request("dd")%>&SearchUC=<%=request("SearchUC")%>&">
<%end if %>下一页</A>★
<%if page=PageCount then%>尾页
<%end if%>
<%if page<PageCount then%>
<A HREF="sou.asp?page=<%=PageCount%>&cxsj=<%=request("cxsj")%>&bb=<%=request("bb")%>&dd=<%=request("dd")%>&SearchUC=<%=request("SearchUC")%>&"> 尾页</A><%end if%>
</p></FONT></td> </tr> <tr>
<td width="105%" align="center" colspan="6">搜索内容:<%=cxsj%></td>
</tr>
</table></center></div>
</body></html>
<%
rs.close
Set rs=nothing
conn.close
set conn=nothing
%>

搜索更多相关主题的帖子: access 数据库 ASP 
2010-03-19 07:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-299860-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.107382 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved