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


how could I change this search function?





typostudy
function search() {
$template = $this->cObj->getSubpart($this->template, '###TEMPLATE_SEARCH###');

$markerArray['###ACTION###'] = $markerArray['###ACTION###'] = $this->pi_getPageLink($GLOBALS['TSFE']->id);
$markerArray['###SEARCH_TITLE###'] = $this->pi_getLL('text_search_title');
$markerArray['###SEARCH_KEYWORD###'] = '<input class="keyword" type="text" name="'.$this->prefixId.'[keyword]"'.($this->piVars['keyword'] ? ' value="'.stripslashes($this->piVars['keyword']).'"' : '').' />';
$markerArray['###SEARCH###'] = $this->pi_getLL('text_search_submit');

$content = $this->cObj->substituteMarkerArray($template, $markerArray);

if ($this->piVars['keyword']) {
$keywords = t3lib_div::trimExplode(' ', $this->piVars['keyword'], true);

$likeClause = '';
if (sizeof($keywords)) {
foreach ($keywords as $index => $word) {
if ($index > 0) {
$likeClause .= ' OR jc.contents LIKE \'%' .$word. '%\'';
} else {
$likeClause .= 'jc.contents LIKE \'%' .$word. '%\'';
}
}

if ($likeClause) $likeClause = '('.$likeClause.')';
}

$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'fe.uid, fe.email, fe.city, fe.tx_jcregister_first_name, fe.tx_jcregister_last_name',
'tx_jcresume_text jc LEFT JOIN fe_users fe ON fe.uid = jc.cruser_id',
$likeClause.' AND jc.active = 1'
);
...
}

Above function works like this:
If I search A B, it will find the resume with A or B word in that.
such as:1. A is good. 2. B is good. 3. A B is good

Now I want to make it function like this:
I. If I search for A+B and it should find every resume with the words A B together,
such as: 1. how are you A B?, 2. A B is coming. 3. A B is good.
II. If I search A B, it will find the resume with both of those 2 words in that, but they do not need be together.
such as: 1.A and B are coming. 2. A will go to B's house. 3. A B are good.

So if I want to see this function, how could I change the above code?
Marcuzzo
are you using dynamic sql in your PHP Code?
jmraker
You could try using full-text searches in your database query to see if it works better

http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html
http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html

http://devzone.zend.com/26/using-mysql-full-text-searching/
http://onlamp.com/onlamp/2003/06/26/fulltext.html
http://viralpatel.net/blogs/2009/04/full-text-search-using-mysql-full-text-search-capabilities.html
sysna
yes you should use full text search, many examples on the net but i think this is the best one :

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html
bukaida
The best way is to integrate the Sphinx search engine API. It is on PHP-Mysql and Free. Has a lot of customization options and one of the fastest search engine available till date. It is extremely useful in handling large data. Even this forum uses the same search engine to handle its enormous number of posts Very Happy

Sphinx Full Text Search
Related topics
Search Fuction in user list
Search function
The Forum Search
integration of search engines
search script.
Your online routine
Search function server load relief.
Add to the search options
the best way to add a search function is?
Our Search
Problem restoring databases
Search Script..?
new zune firmware
PHP search function with MySQL fulltext
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.