By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,348 Members | 1,397 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,348 IT Pros & Developers. It's quick & easy.

MySql search question. Searching on keywords

P: n/a
dpg


How do site searches work?
I want to create a MySQL database with a field called "keywords". Then a
form with a search phrase input box.

I can't figure how to get the results with multiple words using php sql
query. It's easy with just one word. Do you have to run multiple queries
based on each word in the query? Then compile each of the results removing
duplicates.

Plus..how do you sort results based on matching results.

Anybody have any tips?


Jul 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
dpg
Yes, This works good. Thanks Andy
"Andy Jeffries" <ne**@andyjeffries.remove.co.uk> wrote in message
news:pa****************************@andyjeffries.r emove.co.uk...
On Wed, 06 Aug 2003 00:55:18 +0000, dpg wrote:
How do site searches work?
I want to create a MySQL database with a field called "keywords". Then a form with a search phrase input box.

I can't figure how to get the results with multiple words using php sql
query. It's easy with just one word. Do you have to run multiple queries based on each word in the query? Then compile each of the results removing duplicates.


$words = explode(" ", $keywords);
foreach ($words as $word) {
if (isset($where)) {
$where .= " OR ";
}
$where .= "mysearchfield LIKE '%$word%'";
}
$SQL = "SELECT * FROM mysearchtable WHERE $where";

Jul 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.