SELECT * FROM main WHERE nameclient
LIKE :who OR
LIKE :who AND datestart = :datestart OR
LIKE :who AND dateend = :dateend OR
LIKE :who AND datestart BETWEEN :datestart AND :dateend
$sql = 'SELECT * FROM main WHERE nameclient LIKE :who';
if(!empty($_POST['dstart']) && !empty($_POST["dend"])) {
$sql .= 'AND datestart BETWEEN :datestart AND :dateend';
} elseif(!empty($_POST['dstart'])) {
$sql .= 'AND datestart = :datestart';
} elseif(!empty($_POST['dend'])) {
$sql .= 'AND dend = :dend';
}
Barmunk, так лучше, но не в одну строку
foreach($array as $value) if (in_array("108", $value)) return true;