
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
麻烦哪未兄弟直接给个 展开
<%
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
麻烦哪未兄弟直接给个 展开
展开全部
第一次见这么繁琐的写法
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"
字段名根据自己的网站写
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"
字段名根据自己的网站写
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询