This topic is locked

Multiple keywords for searching

2/13/2007 2:11:26 AM
ASPRunnerPro General questions
A
abdemir author

Hi,
My table has keywords field for crop details
ID | Crop| Keywords

01 | Apple | red, small, pip, hard

02 | Banana | yellow, sweet, long, calcium, expensive, tropical

03 | Watermelon | yellow, red, pip, big, heavy, sweet

04 | Cherry | small, sweet, pip, red
I want to search red and sweet crops. I selected containsoption from drop-down menu then entered red, sweetbut I couldn't find them (Waterlemon and Cherry)
How can I search two or more words with advanced search (on advanced page) or basic search (on list page). I can not use mutliple list-box because we have a lot of keywords and we must define products with keywords.
Could you help me please and Best Regards,

Bulent

A
abdemir author 2/13/2007

Hi all,
I changed original code with following my codes on commonfunction.asp, I think it is running and problem is solved. Please post if you have another solution.
You can also apply this solution for the Advanced Search but you should change code variable

( sSearchFor --> SearchFor , StrWhere --> StrWhereAdv, please look at the Function StrWhereAdv(strField, SearchFor, strSearchOption, SearchFor2, etype) )
Original Code

----------------


Function StrWhere(strField, SearchFor, strSearchOption, SearchFor2)

..

...

....

~~if IsCharType(ttype) and not IsTextType(ttype) then

StrWhere = strField & " like " & db_upper("'%" & sSearchFor & "%'")

Exit Function

Else

StrWhere = strField & " like '%" & sSearchFor & "%'"

Exit Function

End If~~

..

...

....

End Function
My Code

-------------------


if IsCharType(ttype) and not IsTextType(ttype) then

Dim _SearchString(100)

x = 1

For i = 1 To Len(sSearchFor)
If Mid(sSearchFor, i, 1) = "," Then

x = x + 1

i= i + 1

else

_SearchString(x) = _SearchString(x) & Mid(sSearchFor, i, 1)

End if

Next
StrWhere = strField & " like " & db_upper("'%" & _SearchString(1) & "%'")

For y = 2 to x

StrWhere = StrWhere & " and " & strField & " like " & db_upper("'%" & _SearchString(y) & "%'")

Next
Exit Function

Else

StrWhere = strField & " like '%" & sSearchFor & "%'"

Exit Function

End If

K
kimz 4/4/2008

Hi,
i know this is an old topic but i really need your help.
i would like to use this search option but it doesn't seem to word anymore with the new asprunner pro. when i use the code i get a 500 page error.
can someone tell me why this code doesn't work anymore?
thanks!
Kim

P
paulyap2k 5/3/2008

I have the same requirement. I have search through the post and does not seems to find an answer to these. Any help would be appreciated.

Regards, Paul