|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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.
|
|
#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'); |
|
#3
|
|||
|
|||
|
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? |
|
#4
|
|||
|
|||
|
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']; ? |
|
#5
|
|||
|
|||
|
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? |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > keyword search |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|