I'm tring to make a search engine for one of my projects.
I have it breaking the search string up into pieces and searching for all the words seperatly. but I want to allow the user to "enclose their search" in "" and it will search for that phrase?
but so far it has not hit me how to do this
so any help will be very usefull thanx
Andrew
[SOLVED] Search
Moderator: General Moderators
- AndrewBacca
- Forum Commoner
- Posts: 62
- Joined: Thu Jan 30, 2003 10:03 am
- Location: Isle of Wight, UK
[SOLVED] Search
Last edited by AndrewBacca on Sun Oct 16, 2005 6:14 am, edited 1 time in total.
Sounds like you'll need a regular expression to extract values between quotes.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- AndrewBacca
- Forum Commoner
- Posts: 62
- Joined: Thu Jan 30, 2003 10:03 am
- Location: Isle of Wight, UK
hmm.. something like
I'm not too sure though, my regular expression experience isn't too great. =/
Code: Select all
$searchquery = $_POST['search'];
preg_match("#\"(.+?)\"#", $searchquery, $matches);
foreach($matches[0] AS $search)
{
mysql_query("SELECT * FROM table WHERE field LIKE '%$search%'");
}Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- AndrewBacca
- Forum Commoner
- Posts: 62
- Joined: Thu Jan 30, 2003 10:03 am
- Location: Isle of Wight, UK