XenoGen Posted March 25, 2010 Share Posted March 25, 2010 I am editing some code that someone else wrote - it's open source code - and I've figured out the area of the code that handles what I need done, and I've changed it a bit. But I need help with one more thing: How the code currently works: Basically, there's a search box - when the user types in a word, the code then searches what's in the variable (intro) and displays only the relevant information. This is good. The Problem: if I type in "United States of America", but part of the text in the variable "intro" has fro example "the United States are great. This is America", it won't show up. Whatever is typed by the user has to be found in exactly the correct order.. even if all the words are contained in the variable, unless it's typed in the exact right order, it won't show up. What I would LIKE it to do: I would like the code to separate EACH word that the user types in, and check them individually to the text that's contained in the variable. I would like it to match ALL words that are typed, just not necessarily in that same order that was searched. For example, if someone typed "america states united" in the search box, and the variable contained "the United States are great. This is America", I would like it to show up. Also, it currently searches the variable "intro" - how can I make it search a second variable, "address" for the same terms, at the same time? Please show me how to change this code so that it seperates each word typed by the user and checks them individually against the "intro" variable. If you could type in the "final" code that I could use, that would be awesome. Thanks! Here's the code. I believe this is all the code you would need to change/add, but if you need more info let me know: if ($search_map) { $wheres[] = 'LOWER( intro ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search_map, true ).'%', false ); } Link to comment https://forums.phpfreaks.com/topic/196475-search-how-to-separate-each-keyword-term/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.