, , .
OR, , :
NOTE. Introductory disinfection and preparation are not indicated.
1 . Request with:
$sql_where = "WHERE name LIKE '%$ser%'";
2. If zero results are returned, ask the user if they want to query each word separately.
3. If the user requests a search for “every word,” query with:
$sql_where = get_sql_where($ser);
(working) Sample code below:
$ser = 'Testing 123';
$msg = '';
function get_sql_where($ser){
global $msg;
$sql_where = '';
$sql_where_or = '';
$ser = preg_replace("/[[:blank:]]+/"," ", trim($ser));
$search_words = explode(" ", $ser);
if($search_words[0] == ''){
$msg = 'Search quested was blank.';
}else{
$msg = 'Search results for any of the following words:' . implode(', ', $search_words);
$sql_where = "WHERE name LIKE '%$ser%'";
foreach($search_words as $word){
$sql_where_or .= " OR name LIKE '%$word%'";
}
}
return $sql_where . $sql_where_or;
}
$sql_where = get_sql_where($ser);
source
share