} function getEmployee($username) { $query = $this->connection->prepare("SELECT username, firstname, surname FROM employees WHERE username = ? LIMIT 1;"); $query->bind_param('s', $username); $query->execute(); $result = $query->get_result(); $row = $result->fetch_assoc(); return new Employee($row['username'], $row['firstname'], $row['surname']); } private $connection; } ?> <form action='listDepartments.php' method='POST'> <input name='term' placeholder='search'><br/> <input type='submit' value="Search"> </form> <?php if (isset($_POST['term'])) { $term = $_POST['term']; $connection = mysqli_connect("localhost", "root", "", "pyus"); $departments = new Departments($connection); foreach ($departments->search($term) as $department) { echo "<b>" . $department->name . "</b></br>"; foreach ($department->roles as $role) { echo $role->name . " " . $role->employee->firstname . " " . $role->employee->surname . "<br/>"; } } }