Orionsbelter Posted March 18, 2009 Share Posted March 18, 2009 hello, am wanting to make a input box where someone will input a word/phases and a word suggestion will come up would the LIKE Function be best for this? Quote Link to comment https://forums.phpfreaks.com/topic/150001-search-box/ Share on other sites More sharing options...
WolfRage Posted March 18, 2009 Share Posted March 18, 2009 Could you be a little more vague? Details man, details? I need to get me a PHP Crystal Ball. Quote Link to comment https://forums.phpfreaks.com/topic/150001-search-box/#findComment-787769 Share on other sites More sharing options...
kickstart Posted March 18, 2009 Share Posted March 18, 2009 Hi Yes, a like. However you might want to search for items the both start with what is typed and contain what is typed (ie, put the ones it starts with first). Something like:- SELECT phrase, "Begins" AS fred FROM some_table WHERE phrase like "searchstring%" UNION SELECT phrase, "Contains" AS fred FROM some_table WHERE phrase like "%_searchstring%" ORDER BY fred All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/150001-search-box/#findComment-787770 Share on other sites More sharing options...
Zane Posted March 18, 2009 Share Posted March 18, 2009 If that's the way you want it to work then yes.. using LIKE--------------- someone searches the word "the".. it will match -the -theme -breathe -thesaurus etc etc etc another way is to use SELECT * FROM table WHERE IN("searchphrase") Quote Link to comment https://forums.phpfreaks.com/topic/150001-search-box/#findComment-787772 Share on other sites More sharing options...
Orionsbelter Posted March 18, 2009 Author Share Posted March 18, 2009 ok say i want to search for hello world then it checks my database and i have two fields one called search next result it finds search(the) result(the hello world...) or gets (the) result(the hello world...) how would that go? Quote Link to comment https://forums.phpfreaks.com/topic/150001-search-box/#findComment-787776 Share on other sites More sharing options...
kickstart Posted March 18, 2009 Share Posted March 18, 2009 Hi Do you mean if you have a search table containing all the possible phrases? Possible (and how the search works for single words in some forum software), but likely to mean a massive table. For example say you had a phrase "she sells sea shells" and wanted a list of all the possible phrases in that to search. Just that simple 4 word phrase would give you:- she she sells she sells sea she sells sea shells sells sells sea sells sea shells sea sea shells shells The number of possible phrases would rapidly massively increase. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/150001-search-box/#findComment-787783 Share on other sites More sharing options...
Orionsbelter Posted March 18, 2009 Author Share Posted March 18, 2009 what i want is for someone to spell a word phonetically such as phone tick lee then the it searches the database to find "phonetically" do you know where am going? Quote Link to comment https://forums.phpfreaks.com/topic/150001-search-box/#findComment-787788 Share on other sites More sharing options...
kickstart Posted March 18, 2009 Share Posted March 18, 2009 Hi There is an algorithm called Soundex to match up words phonetically, although it is meant to be used with names (not sure it would work as well with normal words). Think the word equivalent is called Metaphone. Probably best to have Google for those. There is a php function to calculate the metaphone. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/150001-search-box/#findComment-787804 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.