永发信息网

asp 一段搜索代码问题!

答案:1  悬赏:40  手机版
解决时间 2021-05-02 00:17
  • 提问者网友:轮囘Li巡影
  • 2021-05-01 00:03

<%
where=""
if trim(request.QueryString("keyword"))<>"" then
where=where & "product_name like '%"&trim(request.QueryString("keyword"))&"%'"
end if
if trim(request.QueryString("keyword"))<>"" then
if where="" then
where=where & "xl like '%"&trim(request.QueryString("keyword"))&"%'"
else
where=where & "or xl like '%"&trim(request.QueryString("keyword"))&"%'"
end if
end if
if trim(request.QueryString("keyword"))<>"" then
if where="" then
where=where & "cplx like '%"&trim(request.QueryString("keyword"))&"%'"
else
where=where & "or cplx like '%"&trim(request.QueryString("keyword"))&"%'"
end if
end if
if trim(request.QueryString("keyword"))<>"" then
if where="" then
where=where & "jzm like '%"&trim(request.QueryString("keyword"))&"%'"
else
where=where & "or jzm like '%"&trim(request.QueryString("keyword"))&"%'"
end if
end if
if trim(request.QueryString("keyword"))<>"" then
if where="" then
where=where & "zz like '%"&trim(request.QueryString("keyword"))&"%'"
else
where=where & "or zz like '%"&trim(request.QueryString("keyword"))&"%'"
end if
end if
if trim(request.QueryString("keyword"))<>"" then
if where="" then
where=where & "bc like '%"&trim(request.QueryString("keyword"))&"%'"
else
where=where & "or bc like '%"&trim(request.QueryString("keyword"))&"%'"
end if
end if
if trim(request.QueryString("keyword"))<>"" then
if where="" then
where=where & "qhdj like '%"&trim(request.QueryString("keyword"))&"%'"
else
where=where & "or qhdj like '%"&trim(request.QueryString("keyword"))&"%'"
end if
end if

if trim(request.QueryString("keyword"))<>"" then
if where="" then
where=where & "jbhs like '%"&trim(request.QueryString("keyword"))&"%'"
else
where=where & "or jbhs like '%"&trim(request.QueryString("keyword"))&"%'"
end if
end if

if trim(request.QueryString("keyword"))<>"" then
if where="" then
where=where & "drbh like '%"&trim(request.QueryString("keyword"))&"%'"
else
where=where & "or drbh like '%"&trim(request.QueryString("keyword"))&"%'"
end if
end if


if trim(request.QueryString("keyword"))<>"" then
if where="" then
where=where & "bz like '%"&trim(request.QueryString("keyword"))&"%'"
else
where=where & "or bz like '%"&trim(request.QueryString("keyword"))&"%'"
end if
end if

if where<>"" then
where="where "&where
end if
if where="" then
response.Write "<script language=javascript>alert('搜索內容不能不空!');javascript:history.go(-1)</script>"
response.end
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from ecn " & where & "and pass=1 order by product_name desc"
'response.write sql & "<br>"
rs.open sql,conn,1,1
%>

执行结果 不执行pass=1 这个条件!请高手看下

最佳答案
  • 五星知识达人网友:春色三分
  • 2021-05-01 01:20

where="where "&where


这行改成


where="where ("&where&")"


说句题外话,楼主你的if...end语句用的也太多了,写的不累吗,看的都快累死了,汗~~~

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯