vicodin Posted February 28, 2008 Share Posted February 28, 2008 Ok so this is what i need to do. I havent even tested this code yet but i think it will work. This is what i want to do. It takes the search information and breaks it down into an array by white spaces. It then takes each word and searches the key words section in my database. So what i need to do is if it finds a result output the product, stop looking at the product and go to the next if it finds a result in the keywords... not sure exactly how i would do that... any ideaS? function SearchIt($search){ if (!empty($search)){ $search = CheckData($search); $search = explode(" ",$search); mysql_select_db("*******") or die(mysql_error()); foreach($search as $words){ $query =("SELECT * FROM products WHERE MATCH(keywords) AGAINST('$word') ORDER BY score DESC"); while ($row = mysql_fetch_array($result)){ /*Echo the product */ } } } } Link to comment https://forums.phpfreaks.com/topic/93475-my-product-search-need-some-help-please-p/ Share on other sites More sharing options...
trq Posted February 28, 2008 Share Posted February 28, 2008 So, what results is this code producing that isn't what your after? Link to comment https://forums.phpfreaks.com/topic/93475-my-product-search-need-some-help-please-p/#findComment-478892 Share on other sites More sharing options...
vicodin Posted February 28, 2008 Author Share Posted February 28, 2008 Ok so lets say they search for ARS8000 Optical Machine. and i have ARS8000 Optical in my database under my keywords. its gonna produce two of the same results because its gonna hit on ARS8000 and Optical. I want it when it finds a matching result stop looking at it produce the output and go on to the next entry Link to comment https://forums.phpfreaks.com/topic/93475-my-product-search-need-some-help-please-p/#findComment-478894 Share on other sites More sharing options...
trq Posted February 28, 2008 Share Posted February 28, 2008 SELECT DISTINCT * FROM products WHERE MATCH(keywords) AGAINST('$word') ORDER BY score DESC Link to comment https://forums.phpfreaks.com/topic/93475-my-product-search-need-some-help-please-p/#findComment-478898 Share on other sites More sharing options...
vicodin Posted February 28, 2008 Author Share Posted February 28, 2008 thanks Thorpe!! Link to comment https://forums.phpfreaks.com/topic/93475-my-product-search-need-some-help-please-p/#findComment-478901 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.