Guest mikejshaw Posted October 26, 2008 Share Posted October 26, 2008 Hi, I tried the following code and it works; but it's not specific enough. If I search for 'history' and 'france' it returns titles with either keyword. What do i need to change if i want to find only those products containing all of the search keywords? I tried changing some ORs to ANDs but it didn't work (I'm a cut and paste monkey - not a coder!) Any help appreciated. CODE if(strlen(trim($searchArray[$i])) == 0) { continue; } The above addition means that empty search terms are ignored eg spaces at the begining or the end of a search query (" red and green" OR "red and green ") CHANGE the following query: CODE $like .= "(name LIKE '%".$searchArray[$i]."%' OR description LIKE '%".$searchArray[$i]."%' OR productCode LIKE '%".$searchArray[$i]."%') OR "; TO: CODE $like .= "(name REGEXP '[[:<:]]".$searchArray[$i]."[[:>:]]' OR description REGEXP '[[:<:]]".$searchArray[$i]."[[:>:]]' OR productCode REGEXP '[[:<:]]".$searchArray[$i]."[[:>:]]') OR "; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.