navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

RE: Search using Multiple Keywords

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> RE: Search using Multiple Keywords
Page: <<   < prev  1 [2]
 
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 1/16/2003 13:37:41   
Hisham,

Sorry I left one TINY piece out. It IS included in this post:

<%
Dim Keyw
Dim SubC
Dim myquery
Dim myQuerystring
SubC = Request.form(" SubCategory" )
Keyw = Request.Form(" Keyword" )
if (Keyw = " " Or Keyw = " " ) Then
if (SubC = " " Or SubC = " " ) Then
Keyw = " SELECT * FROM SpecialsDatabase WHERE (ProductType= ' ::ProductType::' ) ORDER BY EQPSpecialPrice ASC"
else
Keyw = " SELECT * FROM SpecialsDatabase WHERE (ProductType= ' ::ProductType::' AND SubCategory= ' ::SubCategory::' ) ORDER BY EQPSpecialPrice ASC"
end if
else
Keyw = split(Request.Form(" Keyword" )," " )
myQuerystring = " (ItemName Like ' %" & trim(Keyw(0)) & " %' "
myQuerystring = myQuerystring & " Or Description Like ' %" & trim(Keyw(0)) & " %' )"
if uBound(Keyw) > 0 Then
for i = 1 to uBound(Keyw)
myQuerystring = myQuerystring & " OR (ItemName Like ' %" & trim(Keyw(i)) & " %' )"
myQuerystring = myQuerystring & " OR (Description Like ' %" & trim(Keyw(i)) & " %' )"
next
end if
if (SubC = " " OR SubC = " " ) Then
Keyw = " SELECT * FROM SpecialsDatabase WHERE (ProductType= ' ::ProductType::' And ("
else
Keyw = " SELECT * FROM SpecialsDatabase WHERE (ProductType= ' ::ProductType::' And SubCategory= ' ::SubCategory::' AND ("
end if
Keyw = Keyw + myQuerystring
Keyw = Keyw + " )) ORDER BY EQPSpecialPrice ASC"
end if
myquery = Keyw
response.write (myquery & " <BR>" )
%>


So that is it. The routine with everything included.
LLLuneeeeeeee :)

_____________________________


(in reply to Long Island Lune)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Search using Multiple Keywords - 1/17/2003 10:44:15   
Hi LLL,

Thanks a lot.

I tried the code, it is working fine. Also try the WHERE IN, it is different.

Hisham

(in reply to Long Island Lune)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 1/17/2003 12:29:42   
Hisham,

I think I' ll test the " WHERE IN" this weekend.

Thanks.
LLLuneeeeee :)


_____________________________


(in reply to Long Island Lune)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 1/17/2003 12:52:51   
Hisham,

Which code did you try, the one you were working on with " WHERE IN" or the " LIKE" code???

Thanks,
LLLuneeeee :)

_____________________________


(in reply to Long Island Lune)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Search using Multiple Keywords - 1/17/2003 13:54:35   
Hi Mark,

It is the IN code, the second one.

Hisham

(in reply to Long Island Lune)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Search using Multiple Keywords - 1/17/2003 13:57:19   
Hi Mark,

This is the code.

quote:

<%DIM myArray, myQuerystring

myArray = split(Request.Form(" keywords" )," " ) ' splitting on spaces
myQuerystring = " "

FOR i = 0 to (uBound(myArray)-1)
myQuerystring = myQuerystring & " ' " & myArray(i) & " ' ,"
NEXT

' don' t want a comma trailing the last one
myQuerystring = myQuerystring & " ' " & myArray(ubound(myArray)) & " ' " %>


Hisham

(in reply to Long Island Lune)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Search using Multiple Keywords - 1/17/2003 13:58:37   
Hi again,

The SQL statement would be:

quote:

Then for your dieted DRW query, maybe something like:

fp_sQry=" SELECT * FROM myTable WHERE keyword IN (" & myQuerystring & " )"


CU
Hisham

(in reply to Long Island Lune)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Search using Multiple Keywords - 1/17/2003 14:00:25   
Hi Mark,

Remember, it worked for me when I created two separate pages not the same one.

Page 1: Will have the search form and post it to the DRW page
Page 2: Will have the DRW with the code above

Put the DRW on diet then change the sql statement.

Regards
Hisham

(in reply to Long Island Lune)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 1/17/2003 18:46:49   
Hisham,

Yes, mine was a two page function too. I couldn' t do it in one. I' m going to play/test your routine and see how it works.

Thanks,
LLLuneeeee :)

_____________________________


(in reply to Long Island Lune)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 1/19/2003 1:07:21   
Hisham,

Your version worked?

Thanks,
LLLuneeeee :)

_____________________________


(in reply to Long Island Lune)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Search using Multiple Keywords - 1/19/2003 9:23:42   
Hi again,

Can you investigate why it is not working in one page? it is strange.

I know when you dig for something you will find, no matter how deep it is.

Thanks
Hisham

(in reply to Long Island Lune)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 1/20/2003 15:57:22   
Hisham,

This could be a deep one, I' m looking into it. I know the answer but I have to try to figure out HOW it post it without if taking up 1000 lines!!!

Stay tuned...

LLLuneeeee :)

_____________________________


(in reply to Long Island Lune)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Search using Multiple Keywords - 1/20/2003 16:11:28   
Hi Mark,

I got this from the new member Tarwn, he is in another forum too. He explained why it did not work on one page and gave the solution. Please read it and let me know what you think:

quote:


Tarwn
Ok, in this instance you would have to skip the code the first time the page loaded, then set the form to submit back to this same page. On the second pass you could then use the code.
The reason behind this is because the ASP is going to execute before the page is ever sent to the user, so by the time the user actually has the form in fron of them and is starting to fill it out, the ASP script is already exiting and gone. This is why you wre egtting an array index out of bounds, because the ASP code was attempting to run before the user even had a chance to fill out the form. Since there was nothing in the form collection yet you were dealing with an empty array.

You would probably be better of doing this in seperate pages, or if you want it in one page then do something like this:
If Request.Form(" Country" ) <> " " Then
' do your submission code here
Else
' display your html form and usch here
End If

This way if there is nothing in the form collection it displays the form, then set the action of the form to this address. If there is something in the form collection it means the page already loaded once and the user has fillerd out the information, so go to thwe submission code and submit it to the db.

Hope this helps,
-Tarwn


Thanks
Hisham

(in reply to Long Island Lune)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 1/20/2003 23:08:10   
Hisham,

This problem reminds me of the old DOS to Windows software changeover of 1985. Programmers then were use to controling software and interaction the DOS way. You could stop software processing and have the program wait until a user interacted with the program in some way. Windows 3.0 of 1985 changed all that. Now halting program execution was not possible the old traditional way due to real-time messaging between objects and windows.

When it comes to doing everything on one-page in Internet devleopment, you need to be able to execute portions of code and have other portions of code stay in a suspened state until the user has interacted with the page in some way.

Tarwn' email offered one way of doing this. It makes sense. He saved me writing a long story and condensed it good. I was thinking along this line myself but wanted to play with it first. I would try it.

_____________________________


(in reply to Long Island Lune)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Search using Multiple Keywords - 1/21/2003 0:24:14   
Hi Mark,

quote:

If Request.Form(" Country" ) <> " " Then
' do your submission code here
Else
' display your html form and usch here
End If


In our case we don' t need submission code, I think we have to replace the ' do your submission code here wit the SQL statement.

Try it when you have time, I will to then we can share the results.

Thanks Mark
Hisham

(in reply to Long Island Lune)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 1/21/2003 0:27:42   
Okay, I' ll check it out. Sounds good.

LLLuneeeee :)

_____________________________


(in reply to Long Island Lune)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 1/21/2003 13:59:46   
Hisham,

Exactly... The SQL assembler should go there.


_____________________________


(in reply to Long Island Lune)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Search using Multiple Keywords - 1/21/2003 15:35:02   
Thanks Mark,

CU

(in reply to Long Island Lune)
LB

 

Posts: 5551
From: Montana USA
Status: offline

 
RE: Search using Multiple Keywords - 1/21/2003 19:35:40   
Hi, guys -

Could you try to be a bit more succinct in your postings? We encourage posting answers in threads rather than private emails so that others can learn also, but a few emails in between in trying to solve something then posting the answer on the thread can be a good thing! :)

Rambling threads just tend to take up server space.... (well... besides boosting one' s Posts [:j])

Sincerely,

Linda

(in reply to hhammash)
hhammash

 

Posts: 1064
Joined: 8/19/2002
Status: offline

 
RE: Search using Multiple Keywords - 1/22/2003 12:44:54   
Hi Linda,

Got the message already, don' t worry?

Hisham

(in reply to LB)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 1/27/2003 23:32:21   
LB,

Message received.


_____________________________


(in reply to hhammash)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 2/3/2003 13:46:12   
Hisham,

I played with the IN code a little. I don' t think it works as good as LIKE does. The results returned were a little different. In the example I tested, LIKE returned 15 files, the same test returned 13 with IN. It confused me. Each method offers itsr own reward I guess. :)

Thanks
LLLuneeeee :)

_____________________________


(in reply to hhammash)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Search using Multiple Keywords - 2/3/2003 14:35:11   
LIKE is a search that uses wildcards (%) - it will locate part of a field.
IN searches for the exact term

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Long Island Lune)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 2/3/2003 15:36:09   
Yes - Spooky you got it. Logical and makes sense. :)

_____________________________


(in reply to hhammash)
Long Island Lune

 

Posts: 2340
Joined: 6/8/2002
From: New York
Status: offline

 
RE: Search using Multiple Keywords - 2/6/2003 23:40:52   
Hisham,

I spent some time playing with code from the site address you gave me a long time ago.

http://www.fmhs.uaeu.ac.ae/immconf/country2.asp

I think spooky hit the nail on the head with wildcards. Nice piece of code though. Great if you know exact matches are what you need.




_____________________________


(in reply to Long Island Lune)
Page:   <<   < prev  1 [2]

All Forums >> Web Development >> ASP and Database >> RE: Search using Multiple Keywords
Page: <<   < prev  1 [2]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts