Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you make a smarter seach?

Status
Not open for further replies.
Jun 9, 2004
188
US
Hello all Here is my problem.
I am searching titles in an article database.
I have two titles:

mouse cleaning
and
cleaning your computer

Now If I do a search for "cleaning mouse" I get 0 results. If I do "cleaning computer' I get 0 results. But If I do mouse cleaning, mouse, cleaning your,I get the articles.

This is my query from a simple form input. The form value is called "search_value"

$query = "SELECT id,title, post, DATE_FORMAT(date,'%M %D, %Y') AS date FROM article WHERE title LIKE '%". $search_value ."%' ORDER BY id DESC LIMIT $offset, $limit";

My question is am I doing something wrong here? Do you have anytips on making a smart search work? This is the only way I was taught where you match the user input to something in the database.

Thanks in advance.
 
You can split the search words on whitespace and join them together with and's to create your where clause. So 'cleaning mouse' becomes "where topic like '%cleaning%' and topic like '%mouse%'.

Or you could use or's for more matches
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top