Jump to content

Search engine with preg_match()


sarathi

Recommended Posts

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

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.