homepage Welcome to WebmasterWorld Guest from 54.237.95.6
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Site Search Help
I need help on my site search script
tongpo




msg:1260439
 2:33 pm on Feb 9, 2005 (gmt 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.

TIA

 

RonPK




msg:1260440
 5:01 pm on Feb 9, 2005 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved