| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 467 人关注过本帖
标题:[求助]ASP搜索和分页 问题
只看楼主 加入收藏
songsong20
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2006-10-11
收藏
 问题点数:0 回复次数:2 
[求助]ASP搜索和分页 问题

<table border="0" width="100%" id="table4" valign="top">
<tr>
<td width="100%" height="24" align="center"><b>产品中心——产品列表</b></td>
</tr>
<tr>
<td width="100%" height="280" valign="top"><table width="100%" height="25" border="0" cellpadding="0" cellspacing="0">
<form name="query" action="query.asp" method="post">
<tr>
<td width="14%" align="right">产品搜索:</td>
<td width="8%" align="right">分类: </td>
<td width="21%"><select name="sort_name">
<option>请选择分类</option>
<option>硒鼓</option>
<option>碳粉</option>
<option>墨水</option>
<option>墨粉</option>
<option>CD-R</option>
<option>CD-RW</option>
</select></td>
<td width="8%" align="right">品牌:</td>
<td width="25%"><select name="brand">
<option selected>请选择品牌</option>
<option>XEROX 施乐</option>
<option>SAMSUNG 三星</option>
<option>PANASONIC 松下</option>
<option>LENOVO 联想</option>
<option>HP 惠普</option>
<option>FOUNDER 方正</option>
<option>EPSON 爱普生</option>
<option>CANON 佳能</option>
<option>TOSHIBA 东芝</option>
<option>SHARP 夏普</option>
<option>RICOH 理光</option>
<option>MINOLTA 美能达</option>
<option>LEXMARK 利盟</option>
<option>BROTHER 兄弟</option>
</select></td>
<td width="24%"><input type="image" name="Submit" src="../images/search.gif" onClick="submitit()"></td>
</tr>
</form>
</table>
<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><span class="STYLE2">产品列表:</span></td>
</tr>
</table>
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("products.mdb")
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from products where sort_name='"&request.Form("sort_name")&"' and brand='"&request.Form("brand")&"' order by id desc",conn,1,1 '我加了WHERE判断以后 分页的时候点下一页的时候 就提示“对不起!没有您查找的数据!” 只能显示首页,没有这个WHERE的判断,分页没有问题,想请大家看下 这个怎么改?
if err.number<>0 then
response.write "数据库中无数据"
end if

'------------------------------------------分页开始
if rs.recordcount=0 then
response.write "对不起!没有您查找的数据!"
else
rs.PageSize =2 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount
page=request("page")

if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if

if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if

rs.AbsolutePage=Page

if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if

For i=1 To x
%>
<table width="100%" height="220" border="1" id="table2" cellspacing="0" cellpadding="2" bordercolorlight="#E6E6E6" bordercolordark="#FFFFFF">
<tr>
<td width="100" align="right">分类:</td>
<td width="259" align="center">&nbsp;<%=rs("sort_name")%></td>
<td width="211" align="center">产品图片:</td>
</tr>
<tr>
<td align="right">品牌:</td>
<td align="center">&nbsp;<%=rs("brand")%></td>
<td rowspan="8" align="center"><img src="displayimg.asp?id=<%=rs("id")%>" border="0"></td>
</tr>
<tr>
<td align="right">产品名称:</td>
<td align="center">&nbsp;<%=rs("product_name")%></td>
</tr>
<tr>
<td align="right">适用于:</td>
<td align="center">&nbsp;<%=rs("purpose")%></td>
</tr>
<tr>
<td align="right">颜色:</td>
<td align="center">&nbsp;<%=rs("color")%></td>
</tr>
<tr>
<td align="right">原装价:</td>
<td align="center">&nbsp;<%=rs("price1")%></td>
</tr>
<tr>
<td align="right">国产价:</td>
<td align="center">&nbsp;<%=rs("price2")%></td>
</tr>
<tr>
<td align="right">装粉价:</td>
<td align="center">&nbsp;<%=rs("price3")%></td>
</tr>
<tr>
<td align="right">备注:</td>
<td align="center">&nbsp;<%=rs("remark")%></td>
</tr>
<tr>
<td colspan="3" align="right">&nbsp;</td>
</tr>
</table>
<%
rs.movenext
next
call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
end if
rs.close
set rs=nothing

Sub PageControl(iCount,pagecount,page,table_style,font_style)
'生成链接
Dim query, a, x, temp
action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")

query = Split(Request.ServerVariables("QUERY_STRING"), "&")
For Each x In query
a = Split(x, "=")
If StrComp(a(0), "page", vbTextCompare) <> 0 Then
temp = temp & a(0) & "=" & a(1) & "&"
End If
Next

Response.Write("<table width=100% border=0 cellpadding=0 cellspacing=0 bgcolor=#f1f1f1>" & vbCrLf )
Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR bgcolor=#f1f1f1>" & vbCrLf )
Response.Write("<TD align=center height=25>" & vbCrLf )
Response.Write(font_style & vbCrLf )

if page<=1 then
Response.Write ("首 页 " & vbCrLf)
Response.Write (" " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=1>首 页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page-1) & ">上一页</A> " & vbCrLf)
end if

if page>=pagecount then
Response.Write (" " & vbCrLf)
Response.Write ("尾 页 " & vbCrLf)
else
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page+1) & ">下一页</A> " & vbCrLf)
Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & ">尾 页</A> " & vbCrLf)
end if

Response.Write(" 页次:" & page & "/" & pageCount & "页" & vbCrLf)
Response.Write(" 共有" & iCount & "个记录" & vbCrLf)
Response.Write(" 转到" & "<INPUT CLASS=wenbenkuang TYEP=TEXT NAME=page SIZE=2 Maxlength=5 VALUE=" & page & ">" & "页" & vbCrLf & "<INPUT CLASS=go-wenbenkuang type=submit value=GO>")
Response.Write("</TD>" & vbCrLf )
Response.Write("</TR></form>" & vbCrLf )
Response.Write("</table>" & vbCrLf )
End Sub
%>
<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>&nbsp;</td>
</tr>
</table> </td>
</tr>
</table>

搜索更多相关主题的帖子: ASP 搜索 
2006-10-27 16:34
songsong20
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2006-10-11
收藏
得分:0 
米人  知道啊   
2006-10-28 09:25
songsong20
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2006-10-11
收藏
得分:0 
我现在就想知道  怎么样把 这个搜索是的 关键字 传递给下一页
2006-10-28 14:33
快速回复:[求助]ASP搜索和分页 问题
数据加载中...
 
   



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

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