vicodin Posted February 28, 2008 Share Posted February 28, 2008 ok im using this statement to search for things in mysql database... $query =("SELECT * FROM products WHERE MATCH(keywords) AGAINST('$words')"); i got it to work by just spacing everything. Now my issue is if the i store the same word in another product neither product will show up. lets say i put in ARS8000 Sony TV and in another product i put ARS7000 Sony TV. It works if i put search ARS8000 or ARS7000 but not if i put Sony TV Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 28, 2008 Share Posted February 28, 2008 Are you running a while loop to display your results? My best guess is that if you aren't, then you are just returning the last row of information from the results. Anyone can correct me if I am wrong. Maybe you could post some more of the code? Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 28, 2008 Author Share Posted February 28, 2008 Heres the code... function SearchIt($search){ if (!empty($search)){ $search = explode(" ",$search); mysql_select_db("mediapil_mkmdata") or die(mysql_error()); foreach($search as $words){ $query =("SELECT * FROM products WHERE MATCH(keywords) AGAINST('$words')"); $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)){ echo''my product output'; } } } } Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 28, 2008 Author Share Posted February 28, 2008 **Bump** Quote Link to comment Share on other sites More sharing options...
premiso Posted February 28, 2008 Share Posted February 28, 2008 Check this out: http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html A natural language search interprets the search string as a phrase in natural human language (a phrase in free text). There are no special operators. The stopword list applies. In addition, words that are present in 50% or more of the rows are considered common and do not match. Full-text searches are natural language searches if no modifier is given. So if this is on a test site and the only two rows you have contain "Sony TV" the above will hit true and not return any rows. I ran into this problem too a while ago. Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 28, 2008 Author Share Posted February 28, 2008 Thank you for your info... Now i know why it was doing that... Any idea if you wan turn that off? Quote Link to comment Share on other sites More sharing options...
premiso Posted February 28, 2008 Share Posted February 28, 2008 As far as I know it cannot be turned off as it is embedded into the binary portion of the code. It was designed that way so lets say you have 1,000 entries in your database, and you try to search for some common terms such as "sony" and "tv". If there are more than 500 records it does not return anything because of the possible toll on the server. Now take that a step up and imagine if you were searching millions of records. Given that, it is a good design to prevent you from attempting to loop/cache about 500,000 records. The only way around it is to not use fulltext searching, or add bogus data so that the 50% mark isn't hit for testing purposes. Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 28, 2008 Author Share Posted February 28, 2008 Makes sense... Just sucks for me. 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.