ASP 模糊搜索 例如像百度那样的
以下是我的搜索代码,我想做成像百度那样的,多个关键字用空格分开搜索。搜索内容在MURL这个字符段里面。<%txt_sclass=Request("txt_sclass")...
以下是我的搜索代码,我想做成像百度那样的,多个关键字用空格分开搜索。搜索内容在MURL这个字符段里面。
<%
txt_sclass=Request("txt_sclass")
txt_Mname=Request("txt_Mname")
txt_Mdate=Request("txt_Mdate")
txt_intro=Request("txt_intro")
Set rs=Server.CreateObject("ADODB.Recordset")
sqlstr="select id,Mname,Mclass,Mdate,Mintro,Murl from tab_image where 1=1"
If txt_sclass<>"" and txt_sclass<>"选择分类" Then sqlstr=sqlstr&" and Mclass="&txt_sclass&""
If txt_Mname<>"" Then sqlstr=sqlstr&" and Murl like '%"&txt_Mname&"%'"
If txt_Mdate<>"" Then sqlstr=sqlstr&" and Mdate='"&txt_Mdate&"'"
If txt_intro<>"" Then sqlstr=sqlstr&" and Mintro like '%"&txt_intro&"%'"
sqlstr=sqlstr&" order by id desc"
rs.open sqlstr,conn,1,1 展开
<%
txt_sclass=Request("txt_sclass")
txt_Mname=Request("txt_Mname")
txt_Mdate=Request("txt_Mdate")
txt_intro=Request("txt_intro")
Set rs=Server.CreateObject("ADODB.Recordset")
sqlstr="select id,Mname,Mclass,Mdate,Mintro,Murl from tab_image where 1=1"
If txt_sclass<>"" and txt_sclass<>"选择分类" Then sqlstr=sqlstr&" and Mclass="&txt_sclass&""
If txt_Mname<>"" Then sqlstr=sqlstr&" and Murl like '%"&txt_Mname&"%'"
If txt_Mdate<>"" Then sqlstr=sqlstr&" and Mdate='"&txt_Mdate&"'"
If txt_intro<>"" Then sqlstr=sqlstr&" and Mintro like '%"&txt_intro&"%'"
sqlstr=sqlstr&" order by id desc"
rs.open sqlstr,conn,1,1 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询