If you have just one field, it's pretty easy, something like this:
select * from table where field like '%word1%' or field like '%word2%';
But we want to create that programmatically. I.e. you can have one or MORE words and not have to code it by hand.
Assuming that the search keywords are fed into the script by a var called $searchwords, and the method is passed in as a 0 for OR and 1 for AND, this should work well enough:
$method = array(0=>" OR ", 1=>" AND ");
$words = split(" +",addslashes($searchwords));
$query = "select * from test where ";
$once=0;
foreach($words as $word){
if ($once) $query.=$method[$andor];
$query.= "field1 like '%$word%'";
$once=1;
}
print $query;