Skip navigation links

MySQL Forums :: PHP :: Need Help With MySQL Code For Basic Search


Advanced Search

Need Help With MySQL Code For Basic Search
Posted by: Scott Rogers ()
Date: February 06, 2013 11:17AM

Hi, the basic search on my site is too specific.. Meaning it's too exact with word order and phrases.

For example, if I search Shoes Red it won't show results for Red Shoes.

If you search for Red Shoe Laces it won't show results for Red Laces (as the word shoe throws off this order). Below is the code that I believe the search box is using. Can anyone tell me how to "loosen" up this search so it's either more broad or so exact word order isn't necessary?

This is the current code:

case 'search':
if (intval($filter) != 0) {
$filter = JString::strtolower($filter);
$id = intval($filter);
$search .= $temp."(a.id = $id OR LOWER(a.ad_headline) LIKE '%".$this->_db->getEscaped($filter,true)."%' OR LOWER(a.ad_text) LIKE '%".$this->_db->getEscaped($filter,true)."%')";
} else {
$filter = JString::strtolower($filter);
$search .= $temp."(LOWER(a.ad_headline) LIKE '%".$this->_db->getEscaped($filter,true)."%' OR LOWER(a.ad_text) LIKE '%".$this->_db->getEscaped($filter,true)."%')";
}
break;
}
}
}
return $search;
}


Any ideas here?

Options: ReplyQuote


Subject Written By Posted
Need Help With MySQL Code For Basic Search Scott Rogers 02/06/2013 11:17AM
Re: Need Help With MySQL Code For Basic Search Scott Rogers 02/06/2013 11:40AM
Re: Need Help With MySQL Code For Basic Search Rick James 02/09/2013 01:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.