set rs=server.createobject("adodb.recordset") sql="select * from news where" keyword=trim(request("keyword")) strkeyword=instr(keyword," ") if strkeyword=0 then'是否爲+号 keyword1=split(keyword,"+") else keyword1=split(keyword," ") end if Arrayi=ubound(keyword1) if arrayi=0 then '隻有一個(gè)關鍵字時(shí),就不用(yòng)執行循環了(le). sql=sql&" (xl like '%"&keyword1(i)&"%' or js like '%"&keyword1(i)&"%')" else for i=0 to Arrayi if i=0 then'循環到第一個(gè)關鍵詞時(shí) sql=sql&" (xl like '%"&keyword1(i)&"%' or js like '%"&Keyword1(i)&"%') and" else if i=arrayi then '循環到最後關鍵詞時(shí) sql=sql&" (xl like '%"&keyword1(i)&"%' or js like '%"&Keyword1(i)&"%')" else sql=sql&" (xl like '%"&keyword1(i)&"%' or js like '%"&Keyword1(i)&"%') and" end if end if next end if |