transparencia Posted October 31, 2010 Share Posted October 31, 2010 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? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 31, 2010 Share Posted October 31, 2010 can you post your code so we have some idea what the code is so we can help 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"; Quote Link to comment Share on other sites More sharing options...
transparencia Posted November 1, 2010 Author Share Posted November 1, 2010 I don't have any code yet, but you are saying that MySQL-wise there is a type of search that allows for this? 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.