回 帖 发 新 帖 刷新版面

主题:请大家帮忙找找错吧!谢谢!

查询的样式:<select name="types1" class="login" id="types1">
        <option value="" selected="selected">类别</option>
        <option value="title" >按标题</option>
        <option value="content">按内容</option>
        <option value="auther">按作者</option>
      </select>
      <input name="key2" type="text" class="login" id="key2" onclick="this.select()" value="请输入关键字" />
      <select name="types" class="login" id="types">
        <option value="" selected="selected">类别</option>
        <option value="title" >按标题</option>
        <option value="content">按内容</option>
        <option value="auther">按作者</option>
      </select>
 <input name="key" type="text" class="login" id="key" onclick="this.select()" value="请输入关键字" />
查询样式结束



<%
    Dim Key,Types,key2,types1
    Key=Request("key")
    Types=Request("Types")
    key=request("key2")
    types1=request("types1")
    If (Key="" and key2="")Then
    Response.Write "<script language='javascript'>alert('你的关键字不允许为空');location.href='Index.asp'</script>"
    response.End()
    end if
    If (Types="title" and types1="content") then
    Sql="select * from NewsInf where title like '%"&Key&"%' and content like '%"&Key2&"%'" 
    elseif (Types="content" and types1="title") then
    Sql="select * from NewsInf where Content like '%"&Key&"%' and title like '%"&Key2&"%'"
    elseif (Types="author" and types1="title") then
    Sql="select * from NewsInf where author like '%"&Key&"%' and title like '%"&Key2&"%'"
    elseif (Types="author" and types1="content") then
    Sql="select * from NewsInf where author like '%"&Key&"%' and content like '%"&Key2&"%'"
    elseif (Types="content" and types1="author") then
    Sql="select * from NewsInf where content like '%"&Key&"%' and author like '%"&Key2&"%'"
    elseif (Types="title" and types1="author") then
    Sql="select * from NewsInf where title like '%"&Key&"%' and author like '%"&Key2&"%'"
    elseif (Types="title" and types1="") then
    Sql="select * from NewsInf where title like '%"&Key&"%'"
    elseif (Types="" and types1="title") then
    Sql="select * from NewsInf where title like '%"&Key2&"%'"
    elseif (Types="author" and types1="") then
    Sql="select * from NewsInf where author like '%"&Key&"%'"
    elseif (Types="" and types1="author") then
    Sql="select * from NewsInf where author like '%"&Key2&"%'"
    elseif (Types="content" and types1="") then
    Sql="select * from NewsInf where content like '%"&Key&"%'"
    elseif (Types="" and types1="content") then
    Sql="select * from NewsInf where content like '%"&Key2&"%'"
    elseif (Types<>"" and types1<>"") then 
    Response.Write "<script language='javascript'>alert('如果只输入单个条件,请将一边留空');location.href='Index.asp'</script>"
    response.End()
    end if
    Set Rs=Server.CreateObject("ADODB.Recordset")
    Rs.Open Sql,conn,1,3
    if not rs.eof then
    i=1
    do while not rs.eof

    %>
    
没有错误,就是查询不对,请大家帮帮忙吧!    

回复列表 (共1个回复)

沙发

你直接将sql语句输出来看看是什么?

我来回复

您尚未登录,请登录后再回复。点此登录或注册