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
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";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.