Jump to content

Advice on product multi-categories


transparencia

Recommended Posts

Hello!

 

I have a database like this:

 

Product Name | Category1 | Category 2 | Category 3

Iphone            | Apple        | Iphone      |

WD HD            | PC            | Hard-drive  | External

Monitor 17"    | LCD Screen|                  |

 

 

What I want to do is to allow people to search for any categories and also the junction of the categories.

 

For example, if the the URL is like this &category=External;PC;Hard-Drive it will show WD HD and all the other products which have any combination of these three categories.

 

Another example, if the URL is like &category=Iphone it will show Iphone. If the URL is &category=LCD screen;Apple it will not show anything, because the ; is basically an AND.

 

The problem is that the keywords could be in any category, so a search for a single keyword would have to be made on all the columns and a search for 3 keywords, like the first example, would have to be made 3 times on these columns for the 3 keywords, which would mean 9 searches in total!!

 

How could I do this the fastest way?

Link to comment
https://forums.phpfreaks.com/topic/217389-advice-on-product-multi-categories/
Share on other sites

can you post your code so we have some idea what the code is so we can help :confused:

 

 

but MYSQL wise you could do

 

$sql="SELECT*, MATCH ('Product Name','Category1','Category2','Category3') AGAINST('"$search"')FROM search WHERE MATCH 
('Product Name','Category1','Category2','Category3')
AGAINST('"$search"') ORDER DESC";

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.