You might get away with
elseif ($searchterm=="#") {
$query="select distinct n from t where name regexp "1234567890";
}
---but I've no idea off the top of my head if it'd match.
Head over to the MySQL manual and look at their options for SELECT. I expect they have a way already figured out...