asp 多条件搜索的问题

<!--#includefile="setup.asp"--><%setrs=server.createobject("adodb.recordset")dimconnd... <!--#include file="setup.asp" -->
<%
set rs=server.createobject("adodb.recordset")
dim conn
dim DBOath
dim rs
dim sql
dim title
dim type123
dim content
title=request("title")
type1=request("type123")
content=request("content")
if trim(title)="" and trim(type123)="" and trim(content)="" then
sql="select * from news_info order by ID asc"
end if
if trim(title)<>"" and trim(type123)="" and trim(content)="" then
sql="select * from news_info where title123 like '%"&trim(content)& "%' order by ID asc"
end if
if trim(title)="" and trim(type123)="" and trim(content)<>"" then
sql="select * from news_info where content35 like '%"&trim(content)& "%' "
end if
if trim(title)="" and trim(type123)<>"" and trim(content)="" then
sql="select * from news_info where type1 like '%"&trim(type1)&"%' "
end if
if trim(title)="" and trim(type123)<>"" and trim(content)<>"" then
sql="select * from news_info where type1 like '%"&trim(type1)&"%' and content35 like '%"&trim(content)&"%' "
sql=sql&" order by ID asc "
rs.open sql,conn,1,1
%>
<td><%=rs("title123")%></td>
<td><%=rs("type1")%></td>
<td><%=rs("content35")%></td>
<td> </td>
</tr>
</table>
<%
rs.Close
end if
Set rs=Nothing
%>
错误是搜索不出来任何结果
这是搜索页面
时间 content
关键字 title
全宗号 type123
数据库
id
content35 时间
type1 全宗号
关键字 title123
麻烦哪未兄弟直接给个
展开
 我来答
林轻灵
2008-03-07 · TA获得超过4541个赞
知道大有可为答主
回答量:2448
采纳率:0%
帮助的人:2138万
展开全部
第一次见这么繁琐的写法
title=request("title")
type1=request("type123")
content=request("content")
sqls="where id>0"
if title<>"" then sqls=sqls&" and title123 like '%"&title&"%' "
if type1<>"" then sqls=sqls&" and type1 like '%"&type1&"%' "
if content<>"" then sqls=sqls&" and content35 like '%"&content&"%' "
sql="select * from news_info "&sqls&" order by ID asc"

字段名根据自己的网站写
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式