sarathi Posted August 4, 2009 Share Posted August 4, 2009 I am trying to make a search engine with preg_match(), so far I have the search go through as 'post', and then I explode it $search=explode($_POST['search'], ' ') by spaces, and I try to match that to the body of each post with preg_match($search, mysql_result($body, $i)) the mysql_result returns the right post. But it doesn;t seem to be matching anything. Link to comment https://forums.phpfreaks.com/topic/168825-search-engine-with-preg_match/ Share on other sites More sharing options...
jonsjava Posted August 4, 2009 Share Posted August 4, 2009 first off. regular expressions can cause overhead. If you have a better way, I'd recommend it. Second, you've gotta pass the results into an array (I'd say use mysql_assoc_res()), then run it through a foreach loop. It'd be faster to do a search against their request, rather than a regular expression search. I can't remember if you can pass regular expressions through MySQL, but if you can, that would be the easiest route. Link to comment https://forums.phpfreaks.com/topic/168825-search-engine-with-preg_match/#findComment-890753 Share on other sites More sharing options...
sarathi Posted August 4, 2009 Author Share Posted August 4, 2009 I'm not sure of any other way to find a word in a string. Is there any other way other than regular expressions? Link to comment https://forums.phpfreaks.com/topic/168825-search-engine-with-preg_match/#findComment-890933 Share on other sites More sharing options...
laffin Posted August 4, 2009 Share Posted August 4, 2009 With MySQL, its called full text search u can find a tutorial here Link to comment https://forums.phpfreaks.com/topic/168825-search-engine-with-preg_match/#findComment-890949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.