[SOLVED] Search

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
AndrewBacca
Forum Commoner
Posts: 62
Joined: Thu Jan 30, 2003 10:03 am
Location: Isle of Wight, UK

[SOLVED] Search

Post by AndrewBacca »

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
Last edited by AndrewBacca on Sun Oct 16, 2005 6:14 am, edited 1 time in total.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

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.
User avatar
AndrewBacca
Forum Commoner
Posts: 62
Joined: Thu Jan 30, 2003 10:03 am
Location: Isle of Wight, UK

Post by AndrewBacca »

anyideas?! :)
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

hmm.. something like

Code: Select all

$searchquery = $_POST['search'];

preg_match("#\"(.+?)\"#", $searchquery, $matches);

foreach($matches[0] AS $search)
{
    mysql_query("SELECT * FROM table WHERE field LIKE '%$search%'");
}
I'm not too sure though, my regular expression experience isn't too great. =/
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.
User avatar
AndrewBacca
Forum Commoner
Posts: 62
Joined: Thu Jan 30, 2003 10:03 am
Location: Isle of Wight, UK

Post by AndrewBacca »

[SOLVED]

got it thx for the help :)
Post Reply