Jump to content

Search issue with my website


McMaster

Recommended Posts

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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.