Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 31st, 2005, 12:48 AM   #1
raikkonen
Newbie
 
Join Date: Jun 2005
Posts: 29
Rep Power: 0 raikkonen is on a distinguished road
Exclamation Search using a few keywords

Hi all, how do i search my database using a few keywords? Say instead of the usual one keyword search,i want to search say 'cat,dog,mouse' instead of maybe 'cat' only. How do i do it? I understand there is a split function but how does it work?

at the moment i have these codes. I have 4 textboxes of inputting the keywords that will lead to the article. then i join them into one field name called 'keywords' inside my database.

strKeyword1=Request("keyword1")
strKeyword2=Request("keyword2")
strKeyword3=Request("keyword3")
strKeyword4=Request("keyword4")
strKeywords=strKeyword1&","&strKeyword2&","&strKeyword3&","&strKeyword4

searchkeyword=Request.QueryString("keywords")
sql="Select * from news where keywords='"&searchkeyword&"'"
multiplekeywords=split(sql,"")
RS.Open sql,Conn,3,3


i figure the problem is from the serachkeyword onwards. I can't get the logic of it - someone pls helpp !!!!!!
raikkonen is offline   Reply With Quote
Old Oct 31st, 2005, 12:58 AM   #2
crazykid48x
Programmer
 
crazykid48x's Avatar
 
Join Date: Apr 2005
Posts: 96
Rep Power: 4 crazykid48x is on a distinguished road
I dont know much bout sql but back when I used mysql I would use OR.

"SELECT * FROM news WHERE keywords="keyword1" OR keywords="keywords2" OR....

I think thats how I did it. Im not sure, its ben a year since ive used mysql.
__________________
I had my portable CD player, and took it in the bathroom with me while I went to pee. And the second I whipped my penis out, the theme song to 'Rocky' started playing. I've never felt more manly than in that moment.
crazykid48x is offline   Reply With Quote
Old Oct 31st, 2005, 1:16 AM   #3
raikkonen
Newbie
 
Join Date: Jun 2005
Posts: 29
Rep Power: 0 raikkonen is on a distinguished road
thanks,guess i could only use that way. But say if i enter keywords into the search textbox using a comma as in 'cat,dog,mouse' it doesnt work? instead it doesnt give me any output at all. how do i implement the commas?

i tried your code..well it gave me this error : expected end of statement

sql="select * from news where keywords="keyword1" or keywords="keyword2" or keywords="keyword3" or keywords="keyword4""

whats wrong? missing " or .. ?
raikkonen is offline   Reply With Quote
Old Oct 31st, 2005, 2:59 AM   #4
crazykid48x
Programmer
 
crazykid48x's Avatar
 
Join Date: Apr 2005
Posts: 96
Rep Power: 4 crazykid48x is on a distinguished road
like I said I really dont know much, but replace the " " around the keywords with ' '. I think that will get it working.

wait a second, why are you up so late? Go to sleep and when you wake up someone smart will have answered your questions properly.
__________________
I had my portable CD player, and took it in the bathroom with me while I went to pee. And the second I whipped my penis out, the theme song to 'Rocky' started playing. I've never felt more manly than in that moment.
crazykid48x is offline   Reply With Quote
Old Oct 31st, 2005, 3:02 AM   #5
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
It may be late where you are, but it is late morning in this part of the world. I wouldn't make any assumptions on his/her nightey-night bedttime.

--EDIT.. ok, so YOU should be the one hittin' the hay.

LOL
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty

Last edited by stevengs; Oct 31st, 2005 at 3:25 AM.
stevengs is offline   Reply With Quote
Old Oct 31st, 2005, 3:04 AM   #6
crazykid48x
Programmer
 
crazykid48x's Avatar
 
Join Date: Apr 2005
Posts: 96
Rep Power: 4 crazykid48x is on a distinguished road
well Im close to the forum time. Its 30 minutes ahead of me. Either way if he takes a nap im sure someone smart will come along while hes sleep.

Edit/reply: *Yawn* I am kinda sleepy but me and my cousin are competing to see who can go the longest without sleep. *Glares at cousin* heh, he wont last much longer.
__________________
I had my portable CD player, and took it in the bathroom with me while I went to pee. And the second I whipped my penis out, the theme song to 'Rocky' started playing. I've never felt more manly than in that moment.

Last edited by crazykid48x; Oct 31st, 2005 at 3:19 AM.
crazykid48x is offline   Reply With Quote
Old Nov 8th, 2005, 8:15 PM   #7
raikkonen
Newbie
 
Join Date: Jun 2005
Posts: 29
Rep Power: 0 raikkonen is on a distinguished road
Hi all, looks like im back at this again. i've been stuck at this for a very long time,can't figure out how to do it. I've done a search, but it can only search using one keyword. I want to be able to search using one or more keywords, separated by a comma. How do i do that? The keywords will only be searched in two fields : Title and Description. Below is my code:

search=Request.form("search")
searchstring=Split(Request.form("search"), ",")

max=ubound(searchstring)

for i=0 to max-1
word = searchstring(i)
sqlsearch=sqlsearch & "title like '%" & word & "%' or descpt like '%" & word & "%'"
if i <> max-1 then
sqlsearch=sqlsearch & " or "
end if
next

Response.Write "XX" & sqlsearch & "XX" <---- this is to print out and see


please tlel me what's wrong,i can only use one word search .As in when i enter keywords like "haha,too" it only returns the entries with the keyword haha but not the "too". WHen i print out the sqlsearch, it turned out that the "too" did not go in ie the print out was like this :

XXtitle like '%haha%' or descpt like '%haha%'XX

HELP !!!!!
raikkonen is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:07 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC