overtune
01-01-2007, 03:21 PM
Hello!
I have a problem that I hope to solve with some help from you!
I'm trying to make a search with a mysql database and php. I have a table (word) in the database with three fields (id, wordQuery, wordRespond). id is the primary key, wordQuery is varchar (255), and is fulltext indexed.
The user should be able to preform a search in a field on the webpage. In this field he/she writes an searchphrase, the searchphrase is placed in an variable ($searchPhrase). The database is searching for any records that contains this phrase or some pieces of it.
E.g. In the coulmn wordQuery is a record that contains the phrase "how do you do". If the user search for "How do you do today my friend", the database should locate this record.
I've tryed to accomplish this with a MATCH AGAINST search. The sql string can look like this:
SELECT wordRespons, MATCH (wordQuery) AGAINST ('$searchPhrase') FROM word;
This string returns all the records from the database. I want it only to find the records that contains the searchPhrase (or some pieces of it).
How do I do this?
Thanks!
I have a problem that I hope to solve with some help from you!
I'm trying to make a search with a mysql database and php. I have a table (word) in the database with three fields (id, wordQuery, wordRespond). id is the primary key, wordQuery is varchar (255), and is fulltext indexed.
The user should be able to preform a search in a field on the webpage. In this field he/she writes an searchphrase, the searchphrase is placed in an variable ($searchPhrase). The database is searching for any records that contains this phrase or some pieces of it.
E.g. In the coulmn wordQuery is a record that contains the phrase "how do you do". If the user search for "How do you do today my friend", the database should locate this record.
I've tryed to accomplish this with a MATCH AGAINST search. The sql string can look like this:
SELECT wordRespons, MATCH (wordQuery) AGAINST ('$searchPhrase') FROM word;
This string returns all the records from the database. I want it only to find the records that contains the searchPhrase (or some pieces of it).
How do I do this?
Thanks!