I am searching the DB for users by name here. I have preg_split() looking for the space between first and last name to split them up and searching for the names separately, but I want to set it up so that if the user just puts in either first or last, it will search both the 'first_name' and 'last_name' fields for the single name put in. Ex. 'Shannon Phillips' will search first_name for Shannon and last_name for Phillips, but if I just put Phillips, I want it to search both first_name and last_name for Phillips. I'm assuming I would just query the DB twice, and somehow append the results from the second query to the end of the first.
function nameProcess(){
if($_SESSION['search_engine_option'] == 'name'){
$name = preg_split("/[\s,]+/", $_SESSION['search_engine_input']);
if(empty($name['0'])){
$first = db_query('SELECT * FROM {tls_active_applicants} WHERE `first_name` = `'.$name['1'].'`');
$last = db_query('SELECT * FROM {tls_active_applicants} WHERE `last_name` = `'.$name['1'].'`');
}elseif(empty($name['1'])){
$first = db_query('SELECT * FROM {tls_active_applicants} WHERE `first_name` = `'.$name['0'].'`');
$last = db_query('SELECT * FROM {tls_active_applicants} WHERE `last_name` = `'.$name['0'].'`');
}
}