asp模糊搜索改为精确搜索!下面打代码,高分求!
<%dimsqldimrsdimqymcdimrssum,maxpage,thepages,viewpage,iifid=""thenmaxpage=30elsemaxp...
<%
dim sql
dim rs
dim qymc
dim rssum,maxpage,thepages,viewpage,i
if id="" then
maxpage=30
else
maxpage=id
end if
dim strUnit,sfilename
strUnit=""
if cfd<>"" and daoda="" and city="全部信息" or city="" then
sql="select * from zx_info where province like '%"&cfd&"%' or area like '%"&cfd&"%' or city like '%"&cfd&"%' order by infoid desc"
elseif cfd="" and daoda<>"" and city="全部信息" or city="" then
sql="select * from zx_info where province2 like '%"&daoda&"%' or area2 like '%"&daoda&"%' or city2 like '%"&daoda&"%' order by infoid desc"
elseif cfd<>"" and daoda<>"" and city="全部信息" or city="" then
sql="select * from zx_info where province like '%"&cfd&"%' or area like '%"&cfd&"%' or city like '%"&cfd&"%' and province2 like '%"&daoda&"%' or area2 like '%"&daoda&"%' or city2 like '%"&daoda&"%' order by infoid desc"
elseif cfd="" and daoda="" and city="客运专线" or city="货运专线" then
sql="select * from zx_info where infotype='"&city&"' order by infoid desc"
elseif cfd<>"" and daoda="" and city="客运专线" or city="货运专线" then
sql="select * from zx_info where infotype='"&city&"' and province like '%"&cfd&"%' or area like '%"&cfd&"%' or city like '%"&cfd&"%' order by infoid desc"
elseif city="客运专线" and cfd="" and daoda<>"" or city="货运专线" then
sql="select * from zx_info where infotype='"&city&"' and province2 like '%"&daoda&"%' or area2 like '%"&daoda&"%' or city2 like '%"&daoda&"%' order by infoid desc"
elseif cfd<>"" and daoda<>"" and city="客运专线" or city="货运专线" then
sql="select * from zx_info where infotype='"&city&"' and province like '%"&cfd&"%' or area like '%"&cfd&"%' or city like '%"&cfd&"%' and province2 like '%"&daoda&"%' or area2 like '%"&daoda&"%' or city2 like '%"&daoda&"%' order by infoid desc"
else
sql="select * from zx_info order by infoid desc"
end if
sfilename="line_search.asp?spic=6&cfd="&server.URLEncode(cfd)&"&daoda="&server.URLEncode(daoda)&"&city="&server.URLEncode(city)&"&showpage="&id&""
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
%> 展开
dim sql
dim rs
dim qymc
dim rssum,maxpage,thepages,viewpage,i
if id="" then
maxpage=30
else
maxpage=id
end if
dim strUnit,sfilename
strUnit=""
if cfd<>"" and daoda="" and city="全部信息" or city="" then
sql="select * from zx_info where province like '%"&cfd&"%' or area like '%"&cfd&"%' or city like '%"&cfd&"%' order by infoid desc"
elseif cfd="" and daoda<>"" and city="全部信息" or city="" then
sql="select * from zx_info where province2 like '%"&daoda&"%' or area2 like '%"&daoda&"%' or city2 like '%"&daoda&"%' order by infoid desc"
elseif cfd<>"" and daoda<>"" and city="全部信息" or city="" then
sql="select * from zx_info where province like '%"&cfd&"%' or area like '%"&cfd&"%' or city like '%"&cfd&"%' and province2 like '%"&daoda&"%' or area2 like '%"&daoda&"%' or city2 like '%"&daoda&"%' order by infoid desc"
elseif cfd="" and daoda="" and city="客运专线" or city="货运专线" then
sql="select * from zx_info where infotype='"&city&"' order by infoid desc"
elseif cfd<>"" and daoda="" and city="客运专线" or city="货运专线" then
sql="select * from zx_info where infotype='"&city&"' and province like '%"&cfd&"%' or area like '%"&cfd&"%' or city like '%"&cfd&"%' order by infoid desc"
elseif city="客运专线" and cfd="" and daoda<>"" or city="货运专线" then
sql="select * from zx_info where infotype='"&city&"' and province2 like '%"&daoda&"%' or area2 like '%"&daoda&"%' or city2 like '%"&daoda&"%' order by infoid desc"
elseif cfd<>"" and daoda<>"" and city="客运专线" or city="货运专线" then
sql="select * from zx_info where infotype='"&city&"' and province like '%"&cfd&"%' or area like '%"&cfd&"%' or city like '%"&cfd&"%' and province2 like '%"&daoda&"%' or area2 like '%"&daoda&"%' or city2 like '%"&daoda&"%' order by infoid desc"
else
sql="select * from zx_info order by infoid desc"
end if
sfilename="line_search.asp?spic=6&cfd="&server.URLEncode(cfd)&"&daoda="&server.URLEncode(daoda)&"&city="&server.URLEncode(city)&"&showpage="&id&""
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
%> 展开
2个回答
展开全部
范例:
模糊搜索:province2 like '%"&daoda&"%'
精确搜索:province2 ="&daoda&"
其他类推
模糊搜索:province2 like '%"&daoda&"%'
精确搜索:province2 ="&daoda&"
其他类推
追问
strUnit=""
if cfd"" and daoda="" and city="全部信息" or city="" then
sql="select * from zx_info where province = '"&cfd&"' or area = '"&cfd&"' or city = '"&cfd&"' order by infoid desc"
我已经这么改了!没什么效果啊!
追答
把 and city="全部信息" or city="" 去掉
这样 搜索的必为 cfd 的结果
Storm代理
2023-07-25 广告
2023-07-25 广告
StormProxies是一家提供动态代理服务器服务的企业,旨在帮助用户更好地管理网络访问和安全。以下是一些关于StormProxies的IP动态代理服务的特点:1. 高匿名性:StormProxies的动态代理服务器具有高匿名性,可以有效...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询