McMaster Posted July 7, 2010 Share Posted July 7, 2010 I have created a search for my website but it doesn't seem to work properly. For example, if I type in "Harrods teddy" it will show results, but if I type in just "teddy" it doesn't show any results what so ever. Can anyone enlighten me here. My mysql query is: $sql = "SELECT * FROM products WHERE keyword1 = '$cat_new' OR keyword2 = '$cat_new' OR keyword3 = '$cat_new' OR keyword4 = '$cat_new' AND (description LIKE '%$cat_new%' OR title LIKE '%$cat_new%' OR keyword1 LIKE '%$cat_new%' OR keyword2 LIKE '%$cat_new%' OR keyword3 LIKE '%$cat_new%' OR keyword4 LIKE '%$cat_new%')"; Any help appreciated here. Link to comment https://forums.phpfreaks.com/topic/207006-search-issue-with-my-website/ Share on other sites More sharing options...
Pikachu2000 Posted July 7, 2010 Share Posted July 7, 2010 According to the logic of that query, there have to be 2 matches to return any result. It, in essence, says (that "one keyword must match exactly with $cat_new) AND (description, title or a keyword must wildcard match $cat_new). Is that how you intended it to work? Link to comment https://forums.phpfreaks.com/topic/207006-search-issue-with-my-website/#findComment-1082493 Share on other sites More sharing options...
McMaster Posted July 7, 2010 Author Share Posted July 7, 2010 That done the trick. Thanks a bunch for that Link to comment https://forums.phpfreaks.com/topic/207006-search-issue-with-my-website/#findComment-1082499 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.