npsari Posted January 2, 2009 Share Posted January 2, 2009 Hello everyone reading this... I will do my best to explain the problem i am facing So, a user comes to my website and uses the search tool i created Lets say he searches for "cheap telephone engineers in the town brighton" Therefore, $key = "cheap telephone engineers in the town brighton"; I order to match his search, i use the following part... <?php $q = "SELECT * FROM ads WHERE ad_keywords LIKE '%{$key}%' ORDER BY RAND() "; ?> The problem is that, It matches the exact term, i need something to match as more words as possible Do you know how can i manage to do that Link to comment https://forums.phpfreaks.com/topic/139211-a-little-problem-in-my-search-tool/ Share on other sites More sharing options...
DarkWater Posted January 2, 2009 Share Posted January 2, 2009 I'd suggest checking out MySQL's FULLTEXT index. Link to comment https://forums.phpfreaks.com/topic/139211-a-little-problem-in-my-search-tool/#findComment-728130 Share on other sites More sharing options...
npsari Posted January 2, 2009 Author Share Posted January 2, 2009 I tried to find something, but i couldnt All i end up with is this page http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html Which uses LIKE too Link to comment https://forums.phpfreaks.com/topic/139211-a-little-problem-in-my-search-tool/#findComment-728139 Share on other sites More sharing options...
dennismonsewicz Posted January 2, 2009 Share Posted January 2, 2009 try looking at this tutorial http://www.webreference.com/programming/php/search/2.html Link to comment https://forums.phpfreaks.com/topic/139211-a-little-problem-in-my-search-tool/#findComment-728144 Share on other sites More sharing options...
npsari Posted January 2, 2009 Author Share Posted January 2, 2009 Thank you for the link The thing is, this article still uses one word only I need the query to match as much words possible from $key hmm, I guess i will have to do it another way I need to do a trick in php, use arrays maybe Link to comment https://forums.phpfreaks.com/topic/139211-a-little-problem-in-my-search-tool/#findComment-728170 Share on other sites More sharing options...
DarkWater Posted January 2, 2009 Share Posted January 2, 2009 Wait. Is ad_keywords column a CSV with a bunch of keywords in it? If it is, that's horrible database design and should most definitely be rewritten into another table with a one-to-many relationship with the ads table. Link to comment https://forums.phpfreaks.com/topic/139211-a-little-problem-in-my-search-tool/#findComment-728173 Share on other sites More sharing options...
dennismonsewicz Posted January 2, 2009 Share Posted January 2, 2009 you could also try this link... it talks about using keywords http://www.devarticles.com/c/a/MySQL/Developing-A-Site-Search-Engine-With-PHP-And-MySQL/ Link to comment https://forums.phpfreaks.com/topic/139211-a-little-problem-in-my-search-tool/#findComment-728174 Share on other sites More sharing options...
npsari Posted January 2, 2009 Author Share Posted January 2, 2009 Wait. Is ad_keywords column a CSV with a bunch of keywords in it? If it is, that's horrible database design and should most definitely be rewritten into another table with a one-to-many relationship with the ads table. Yes, i have a colomn which is called: ad_keyword I store the keywords there separated by spaces Really, is that bad design I can easily get data from it though, i just need to sort out the matching part Link to comment https://forums.phpfreaks.com/topic/139211-a-little-problem-in-my-search-tool/#findComment-728223 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.