Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 29th, 2003, 08:22 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
keyword search

I'm probably missing the answer in the forums, but I can't find what I need. I've seen how to search multiple fields with one keyword, but I'd like to find out how to search one field with multiple keywords. So if a user adds 3 words to search by into a text field, the query will search only one field for those 3 words.

Reply With Quote
  #2  
Old November 30th, 2003, 06:45 AM
Seadoo Seadoo is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 133 Seadoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: keyword search

There is a nice function MATCH, see http://www.mysql.com/doc/en/Fulltext_Search.html.

SELECT id, FROM articles WHERE MATCH (body) AGAINST ('Security implications of running MySQL as root');

Reply With Quote
  #3  
Old November 30th, 2003, 03:37 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: keyword search

I tried this query...

$query=("SELECT * FROM recipes WHERE MATCH (ingredients) AGAINST ('$keyterm')");

This returns all entries in the database when it shouldn't. The name of the input from the form is "keyterm". Do I need to add "%" 's?

Reply With Quote
  #4  
Old November 30th, 2003, 04:03 PM
Seadoo Seadoo is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 133 Seadoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: keyword search

Echo out the query string and tell me what it prints on the screen:

echo "SELECT * FROM recipes WHERE MATCH (ingredients) AGAINST ('$keyterm')";

Are you sure you are using $keyterm=$_POST['keyterm']; ?

Reply With Quote
  #5  
Old November 30th, 2003, 04:10 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: keyword search

Ok, I saw my mistake...I forgot the

$result=mysql_query($query);

after the query. However, it doesn't seem to find matches where there are only a couple of ingredients. For example, as a test I added PBJ, with ingredients of peanut butter, jelly, and bread. The search won't find bread, but finds the other 2 ingredients on the keyword search. Any idea why this is?

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > keyword search


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT