日期:2014-05-17  浏览次数:20787 次

一个多关键字查询,查询关键字亮红显示的问题
做了个多关键字查询,想实现如百度那样查询的关键子在结果中红色显示的效果,我是这样写的
searchdatatmp=split(wd, "   ")  
max=ubound(searchdatatmp)

str=rs( "title ")
if   max=0   then
str1=searchdatatmp(i)
invert=replace(str,str1, " <font   color=ff0000> "&str1& " </font> ")
response.Write(invert)
else
for   i=0   to   max  
invert=replace(str,str1, " <font   color=ff0000> "&str1& " </font> ")
response.Write(invert)
end   if
exit   for  
next
end   if

现在一个关键字没问题,但多个关键字效果就出不来,新闻标题成了重复显示了

------解决方案--------------------
searchdatatmp=split(wd, " ")
max=ubound(searchdatatmp)
str=rs( "title ")
for i=0 to max
str=replace(str,searchdatatmp(i), " <font color=ff0000> "&searchdatatmp(i)& " </font> ")
next
response.Write(str)