搜索代码,多参数查询,试过很多次,查询的结果都不会显示,反而全部内容都显示,如何解决啊?
<!--#include file="Include/ConnUrl.asp"--><%
Keyword=SafeRequest("Keyword",0)
%>
<html><head><meta http-equiv="Content-Language" content="zh-cn"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>集团样品图片管理系统图片:搜索:<%=Keyword%></title><link href="Images/style.css" rel="stylesheet" type="text/css"></head><body topmargin="0" leftmargin="0"><!--#include file="Top.Asp"--><table align="center" border="0" cellpadding="0" style="border-collapse: collapse" width="770" id="table1" height="32"><tr>
<td height="32" background="images/TitleBg.gif" width="110" align="right">图片综合搜索:</td>
<td height="32" background="images/TitleBg.gif" width="227"><font color=red><%=keyword%></font> </td><td height="32" background="images/TitleBg.gif" width="100"><p align="center"><a href="Index.asp">返回首页</a></td><form method="get" action="Search1.Asp"><td height="32" background="images/TitleBg.gif" width="100"><input type="text" name="Keyword" size="10"></td>
<td background="images/TitleBg.gif" width="100"><p align="center"><select name="select1">
<%
sql2="select * from ImgClass"
set rs2=server.createobject("adodb.recordset")
rs2.open sql2,conn,1,1
'if NOT rs2.EOF then
while not rs2.EOF
%>
<option value=<%=rs2("ClassName")%>><%=rs2("ClassName")%></option>
<%
rs2.MoveNext
wend
rs2.close
%>
</select>
</td>
<td background="images/TitleBg.gif" width="100"><p align="center"><select name="select2">
<%
sql3="select * from ImgCountry"
set rs3=server.createobject("adodb.recordset")
rs3.open sql3,conn,1,1
'if NOT rs3.EOF then
while not rs3.EOF
%>
<option value=<%=rs3("Country")%>><%=rs3("Country")%></option>
<%
rs3.MoveNext
wend
rs3.close
%>
</select>
</td>
<td background="images/TitleBg.gif" width="100"><p align="center"><select name="select3">
<%
sql4="select * from ImgQuantity"
set rs4=server.createobject("adodb.recordset")
rs4.open sql4,conn,1,1
'if NOT rs4.EOF then
while not rs4.EOF
%>
<option value=<%=rs4("Quantity")%>><%=rs4("Quantity")%></option>
<%
rs4.MoveNext
wend
rs4.close
%>
</select>
</td>
<td height="32" background="images/TitleBg.gif" width="71"><input type="submit" value="综合搜索" name="B1"></td></form></tr></table><%
const MaxPerPage=16
dim totalPut
dim CurrentPage
if not isempty(request("page")) then
currentPage=SafeRequest("page",1)
else
currentPage=1
end if
set rs=server.createobject("adodb.recordset")
Sql = "Select * from [ImgData]"
if request("Photo_Content")<>"" then
sql=sql &" where Photo_Content like '%"& request("Photo_Content") &"%' "
end if
if request("ImgClass")<>"" then
sql=sql &" and Classname like '%"& request("ImgClass") &"%' "
end if
if request("ImgCountry")<>"" then
sql=sql &" and Country like '%"& request("ImgCountry") &"%' "
end if
if request("ImgQuantity")<>"" then
sql=sql &" and Quantity like '%"& request("ImgQuantity") &"%' "
end if
rs.open sql,conn,1,1
if rs.eof and rs.bof then
Response.Write "<br><br><div align=center>还没有任何图片。</div>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"Search1.Asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"Search1.Asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"Search1.Asp"
end if
end if
rs.close
set rs = nothing
end if
sub showContent
dim i
i=1
%><br><div align="center"><table border="1" width="550" cellspacing="0" cellpadding="6" height="48" bordercolor="#F0F0F0" style="border-collapse: collapse">
<tr align="center"><td width="26">序号</td>
<td width="118">图片名称</td>
<td width="118">产地国别</td>
<td width="120">含量</td>
<td width="118">加入时间</td></tr><%do while not rs.eof%> <tr align="center"><td width="26"><%=i%></td><td width="118"><a href=View.Asp?ID=<%=rs("ID")%> target="_blank"><%=Replace(Rs("Photo_Name"),Keyword,"<font color=red><b>"&Keyword&"</b></font>")%></a></td>
<td width="118"><%=rs("Country")%> </td>
<td width="120"><%=Replace(Rs("Photo_Content"),Keyword,"<font color=red><b>"&Keyword&"</b></font>")%> </td>
<td width="118"><%=rs("Intime")%> </td></tr><%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%> </table>
</div><br><%
end sub
function showpage(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<table cellspacing=1 width='100%' border=0 colspan='4' ><form method=Post action="""&filename&"""><tr><td align=center> "
if CurrentPage<2 then
response.write "共<b><font color=red>"&totalnumber&"</font></b>张图片 首页 上一页 "
else
response.write "共<b><font color=red>"&totalnumber&"</font></b>张图片 <a href="&filename&"?Keyword="&Keyword&"&page=1>首页</a> "
response.write "<a href="&filename&"?Keyword="&Keyword&"&page="&CurrentPage-1&">上一页</a> "
end if
if n-currentpage<1 then
response.write "下一页 尾页"
else
response.write "<a href="&filename&"?Keyword="&Keyword&"&page="&(CurrentPage+1)&">"
response.write "下一页</a> <a href="&filename&"?Keyword="&Keyword&"&page="&n&">尾页</a>"
end if
response.write " 页次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
response.write " <b>"&maxperpage&"</b>张图片/页 "
%> </td></tr></table><%end function%><br><!--#include file="Foot.Asp"--></body></html>
[ 本帖最后由 wed080725 于 2011-9-8 11:20 编辑 ]