Jump to content

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.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.