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

 

Search without requiring exact phrase

 
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 >> Search without requiring exact phrase
Page: [1]
 
jonance

 

Posts: 298
From: Louisville KY USA
Status: offline

 
Search without requiring exact phrase - 9/27/2003 22:21:43   
Hi,

If i have a smple search form to search a column of a database, how can i get it so if someone enters two words, that it will retrieve a result even if that EXACT PHRASE isn't in the title but both words are. For example:

If the itemname is "411 The First Step Video" and someone enters '411 video' into my search box, it won't retrieve the record. Apparently it has to be an exact match. How can i change this?

Here is my code:

SELECT * FROM products WHERE (itemname LIKE '%::search::%') ORDER BY ::SortColumn::

Thanks in advance,
John
Spooky

 

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

 
RE: Search without requiring exact phrase - 9/27/2003 23:51:58   
Try :

Search=Replace(Request("Search")," ","%")
SELECT * FROM products WHERE (itemname LIKE '%"&Search&"%') ORDER BY ::SortColumn:: 


_____________________________

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

§þ:)


(in reply to jonance)
jonance

 

Posts: 298
From: Louisville KY USA
Status: offline

 
RE: Search without requiring exact phrase - 9/28/2003 0:18:40   
Thanks, i hope we're on the right track...but i got this error in frontpage. When i went and pasted that in the "edit" portion of the drw, i got the message saying an error was encountered...here is the error. I am looking forward to figuring this out as i have about 20 sites i'd like to change to search this way...thanks for helping me out:

Server error: Unable to retrieve schema information from the query:

Search=Replace(Request("Search")," ","%")

SELECT * FROM products WHERE (itemname LIKE '%"&Search&"%') ORDER BY 1

against a database using the connection string

DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=fpdb/louisvilleguide.mdb.

The following error message comes from the database driver software; it may appear in a different language depending on how the driver is configured.
-------------------------------------------------------
[Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.

Source: Microsoft OLE DB Provider for ODBC Drivers
Number: -2147217900 (0x80040e14)

(in reply to jonance)
Spooky

 

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

 
RE: Search without requiring exact phrase - 9/28/2003 14:11:56   
What does your actual changed code look like?
Is it a dieted DRW?

_____________________________

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

§þ:)


(in reply to jonance)
jonance

 

Posts: 298
From: Louisville KY USA
Status: offline

 
RE: Search without requiring exact phrase - 9/28/2003 18:36:17   
I didn't put it on the diet yet. I just tried to use the drw and do the custom sql query...that is where it rejected it. I know how to put it on the diet and will do so, can you just explain where to put that code? I see where the second linne would go (after fp_sQry i assume)..but how about that first line? Here is my UNEDITED code after the diet....thanks again for your help. John

quote:


<%
fp_sQry="SELECT * FROM products WHERE (itemname LIKE '%::search::%') ORDER BY ::SortColumn::"
fp_sDefault="SortColumn=brands"
fp_sNoRecords="<tr><td colspan=12 align=left width=""100%"">No products matched your search criteria...</td></tr>"
fp_sDataConn="louisvilleguide"
fp_iMaxRecords=0
fp_iCommandType=1
fp_iPageSize=20
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice="itemname"
fp_sMenuValue="itemname"
fp_iDisplayCols=12
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>


(in reply to jonance)
Spooky

 

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

 
RE: Search without requiring exact phrase - 10/3/2003 18:39:38   
Yes, after a diet do :

<% 
Search=Replace(Request("Search")," ","%")
fp_sQry="SELECT * FROM products WHERE (itemname LIKE '%"&Search&"%') ORDER BY ::SortColumn::" 


_____________________________

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

§þ:)


(in reply to jonance)
jonance

 

Posts: 298
From: Louisville KY USA
Status: offline

 
RE: Search without requiring exact phrase - 10/6/2003 11:07:08   
Thanks spooky..it works except for one thing. The 'next', 'prev', etc. buttons do not work properly with that code. For example:

Go to http://www.axiomskatesales.com/searchtest2.asp

Do a search for 'black'. Then scroll down and click 'next'...see the error on the next page, and it returns no results. Is there any way to get that to work with this code?

Thanks,
John

(in reply to jonance)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Search without requiring exact phrase
Page: [1]
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