打印

[asp] 搜索问题

复制内容到剪贴板
代码:
ClassID = GetVariable("ClassID")
TxtCode = GetVariable("TxtCode")
if TxtCode<>"" then    
    PhotoSQL = "select * from Photo where Deleted = false and Passed = true and ClassID="&ClassID&" and  Keyword like '%"&TxtCode&"%' "    
    else
    PhotoSQL = "select * from Photo where Deleted = false and Passed = true and ClassID="&ClassID&""
end if
    if ClassID<>"" then
    PhotoSQL = "select * from Photo where Deleted = false and Passed = true and ClassID="&ClassID&" and  Keyword like '%"&TxtCode&"%' "
    else
    PhotoSQL = "select * from Photo where Deleted = false and Passed = true and ClassID="&ClassID&""
end if
其中ClassID是类别变量,TxtCode是关键字变量
我的功能完成了classid数据库里面有的,但现在前台要搜索,全部的产品,数据库里面没有id可以传递过来,就剩下这个功能实现不了,请各位大侠帮忙.

TOP

复制内容到剪贴板
代码:
PhotoSQL = ""
if ClassID<>"" then PhotoSQL = " and ClassID="&ClassID
if TxtCode<>"" then PhotoSQL = PhotoSQL & " and Keyword like '%"&TxtCode&"%'"
PhotoSQL = "select * from Photo where Deleted = false and Passed = true" & PhotoSQL
淡泊以明志 宁静而致远

TOP