FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Search engine function





jmraker
Does anyone have a function that can search a string or a database as a search engine would that allows freeform AND, OR, + - and quotation marks statements like
Quote:
"Car Wreck" or "Boat Wreck" +funny
or
Quote:
music AND classic -mozart
and determine the search matches a string from the database like "... Car Wrecks are not funny ..."
kv
Have a look at mysql full text search functions.

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html
albuferque
Well, it's not a function but you can try to adapt this script according your needs (sections you have to modify are UPPERCASE):

http://www.mediafire.com/file/1nht1hyhed2/searchscript.zip

Very Happy Very Happy Very Happy
riccopt
why don't you add google search on the site? it is a very god option... free and easy to manage...
jmraker
There's a few reasons why not to use google
1. It needs to search something that isn't publicly available, it's paid content and making a security hole for their bots to get in isn't the best idea
2. It needs to work via ajax and your too lazy to figure out how to do that with google

This is what I used thanks to riccopt
Code:
$fnd[] = '/ and not( *)/i';   $rep[] = ' -';
$fnd[] = '/ not( *)/i';   $rep[] = ' -';
$fnd[] = '/ and( *)/i';   $rep[] = ' +';
$fnd[] = '/ or( *)/i';      $rep[] = ' ';
$form_keywords = preg_replace($fnd, $rep, stripslashes($form_keywords));
$match = 'MATCH(content_title, content_contents, content_box, content_author) ';
$against1 = 'AGAINST(\'' . str_replace('\'', '\\\'', $form_keywords) . '\')';
$against2 = 'AGAINST(\'' . str_replace('\'', '\\\'', $form_keywords) . '\' IN BOOLEAN MODE)';
$query = 'SELECT *, ' . $match . $against1 . ' AS score FROM content, content_category WHERE content_category=content_category_id AND ' . $match . $against2 . ' HAVING score >= 0 ORDER BY score DESC, content_id DESC';
Related topics
Yahoo developing an audio search engine!
Basic Search Engine Optimizing
Make search engine With PHP and mySQL, for your site
Search Engine Scrips
submit to search Engine
What Did We Learn From The Great Search Engine Experiment
Google's Search Engine Performance Drop
Search Engine optimisation tutorial.
Integrate Personal search engine
Is Google really a great search engine?
role on advertisements on the search engine rankings
search engine?
Search engine for the forums
Microsoft's new search engine Bing
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.