| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 397 人关注过本帖
标题:搜索代码,多参数查询,试过很多次,查询的结果都不会显示,反而全部内容都显示 ...
只看楼主 加入收藏
wed080725
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-9-8
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
搜索代码,多参数查询,试过很多次,查询的结果都不会显示,反而全部内容都显示,如何解决啊?
<!--#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>张图片&nbsp;首页 上一页&nbsp;"
      else
            response.write "共<b><font color=red>"&totalnumber&"</font></b>张图片&nbsp;<a href="&filename&"?Keyword="&Keyword&"&page=1>首页</a>&nbsp;"
            response.write "<a href="&filename&"?Keyword="&Keyword&"&page="&CurrentPage-1&">上一页</a>&nbsp;"
      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 "&nbsp;页次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
    response.write "&nbsp;<b>"&maxperpage&"</b>张图片/页 "
%> </td></tr></table><%end function%><br><!--#include file="Foot.Asp"--></body></html>

[ 本帖最后由 wed080725 于 2011-9-8 11:20 编辑 ]
搜索更多相关主题的帖子: content include 管理系统 border center 
2011-09-08 08:52
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:20 
把各阶段的sql语句输出 实在看不出来就把输出的语句在sqlserver或者access里面运行一下就知道了
2011-09-08 10:17
wed080725
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-9-8
收藏
得分:0 
回复 2楼 aspic
其实我上面的代码已经显示出来的效果,但是点击搜索的时候,还是把所有的资料都显示出来,没有按照条件去筛选出来,
图片附件: 游客没有浏览图片的权限,请 登录注册


Imgclass表里有classname
Imgcountry表里有country
Imgquantity表里有quantity
Imgdata表里有classname\country\quantity

[ 本帖最后由 wed080725 于 2011-9-8 11:18 编辑 ]
2011-09-08 11:14
快速回复:搜索代码,多参数查询,试过很多次,查询的结果都不会显示,反而全部内容都 ...
数据加载中...
 
   



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

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