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 */ } } } } Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 28, 2008 Author Share Posted February 28, 2008 thanks Thorpe!! 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.