Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Site Search Help

I need help on my site search script

2:33 pm on Feb 9, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 14, 2004
votes: 0

Ok Im trying to create a search results page for my web site and I just cannot figure it out. My code at the moment is like this:

$query = "SELECT * FROM links WHERE ((description OR title like '%$search_string%') AND (links.confirmed = 'yes')) $limit";
$result = mysql_query($query);

Trouble is it returns some results that are nothing like the search string and also fails to return some results that are like the search string. I have tried variations of the above and still cannot get it to do what I want. I just want the script to search two columns and return all results that match and that are like the search string regardless of case sensitivity. I have been playing around with this for a few days now and I am stuck.

Can anyone help me or point me in the right direction. Does anyone know of any good sites that provide good tutorials? Not just basic tutorials but a good in depth one on a site search?

Also the above code will only return matches on the entire phrase right? How do I get it to search for a through each search word if there are multiple words? I think it is by using the explode function in php right? ANyway I would just like to get the above working and then I can start on matching phrases, any words, all words etc.


5:01 pm on Feb 9, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 22, 2002
votes: 0

> SELECT * FROM links WHERE ((description OR title like '%$search_string%') AND (links.confirmed = 'yes'))

You'll probably need something like this:
SELECT * FROM links WHERE ((description like '%$search_string%' OR title like '%$search_string%') AND (links.confirmed = 'yes'))

Maybe MySQL's full text search [dev.mysql.com] can help with searching for multi-word strings.