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? Link to comment https://forums.phpfreaks.com/topic/217389-advice-on-product-multi-categories/ 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"; Link to comment https://forums.phpfreaks.com/topic/217389-advice-on-product-multi-categories/#findComment-1128774 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? Link to comment https://forums.phpfreaks.com/topic/217389-advice-on-product-multi-categories/#findComment-1128810 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.