Splitting up url parameters for a 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
eromein
Forum Newbie
Posts: 7
Joined: Fri May 06, 2005 7:35 am

Splitting up url parameters for a search.

Post by eromein »

Hi,

I'm creating a search function. When a search on two words (foo bar) I want to find ever record containing foo OR bar.

How do I split up my url (...keyword=foo+bar...) to create a good mySQL query the best way?

Kind regards,

Emiel Romein
Netherlands, the
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

$Keywords = explode (" ",$searchString);
Traverse through the array and create a single SQL statement that adds
LIKE %'.$Keywords[$i].'% AND
to the SQL statement.
Post Reply