1. When you need a dynamic Search Query where variable parameters are presents you can use the following approach: $sql = “SELECT * FROM users WHERE “; $where = array(“dist_id = :dist_id”); $params = array(‘:dist_id’ => $distID); if (isset($p->username) && !empty($p->username)) { array_push($where, “username LIKE :username”); $params[‘:username’] = “%{$p->username}%”; } if (isset($p->firstname) && !empty($p->firstname)) { […]