Split the input name into two vars (or an array) and do something similar to tekno's SQL statement. Although depending on the requirements, you might want to use the "LIKE" statement to perform partial matches.
For a loose search I typically do something like:
eg:
PHP Code:
$k = 'SMITH, MIKE';
$k = preg_replace('/\,/', ' ', trim($k));
$k = preg_replace('/\s+/', ' ', trim($k));
$terms = explode(' ', trim($k));
$sql = '(';
while(list($i, $v) = each($terms)) {
if ($i > 0) {
$sql .= 'OR ';
}
$sql .= "(last_name LIKE '%{$v}%' OR first_name LIKE '%{$v}%') ";
}
$sql .= ')';
$sql = "SELECT ID FROM table_name WHERE {$sql}";
echo $sql;