function getTableWithAllDepartments($universityName) { $departments = getDepartmentsNames($universityName); $output = "<table><tr><th>Department Name</th></tr>"; if (isset($departments) && $departments != null) { foreach ($departments as $i => $departmentName) { $output .= "<tr><td>{$departmentName}</td></tr>"; } } $output .= "</table>"; return $output; }
<?php include 'functions.php'; if (!empty($_POST)) { foreach ($_POST as $key => $value) { switch ($key) { case 'universityName': if (!empty($_POST[$key])) { $universityName = $_POST[$key]; $dep = getDepartmentsNames($universityName); echo generateOptions($dep); } break; case 'universityNameAndReturnDepartmentId': if (!empty($_POST[$key])) { $universityName = $_POST[$key]; $dep = getDepartments($universityName); echo generateOptionsWithSpecifiedValueField($dep, 'departmentId', 'departmentName'); } break; case 'departmentIdAndReturnProfessorId': if (!empty($_POST[$key])) { $departmentId = $_POST[$key]; $pro = getProfessors($departmentId); echo generateOptionsWithSpecifiedValueField($pro, 'professorId', 'professorUsername'); } break; case 'departmentIdAndReturnSecretaryId': if (!empty($_POST[$key])) { $departmentId = $_POST[$key]; $sec = getSecretaries($departmentId);