t_machine Posted December 24, 2007 Share Posted December 24, 2007 I am wondering if anyone can help with this. I already know the basics of searching mysql but if the user has a space, it does not treat the search as "OR". Example: Seach phrase => "cool car" Notice the space? For some reason my results are only if the exact phrase cool car exists but not cool bike or red car. How can I have it search mysql and return any matches even if the phrase does not exists? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/83053-solved-how-to-search-msql-using-or/ Share on other sites More sharing options...
shlumph Posted December 24, 2007 Share Posted December 24, 2007 explode the phrase into an array, then iterate through the array of search words creating a seperate query for each word or, if it's possible use the OR keyword inbetween every word in the array, something like: SELECT * FROM table WHERE name LIKE word1 OR word2 OR word3 OR word4; I'm not sure if this is possible, though, you'll have to test it out Quote Link to comment https://forums.phpfreaks.com/topic/83053-solved-how-to-search-msql-using-or/#findComment-422449 Share on other sites More sharing options...
t_machine Posted December 24, 2007 Author Share Posted December 24, 2007 Thanks very much The array was what i needed. I just made sure to check first it is an array and during the loop check if it's the first result. If it is the first result, I just remove the "OR". Works great! Quote Link to comment https://forums.phpfreaks.com/topic/83053-solved-how-to-search-msql-using-or/#findComment-422466 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.