function generate_department_id() { include 'db_auth.php'; $department_id = "DEPARTMENT_" . rand(0, 999); $existing_ids = mysqli_num_rows(mysqli_query($conn, "select `departments`.`department_id` from `departments` where `departments`.`department_id`='{$department_id}'")); switch ($existing_ids) { case 0: return $department_id; break; default: generate_faculty_id(); } }
function generate_faculty_id() { include 'db_auth.php'; $faculty_id = "FACULTY_" . rand(0, 999); $existing_ids = mysqli_num_rows(mysqli_query($conn, "select `faculty`.`faculty_id` from `faculty` where `faculty`.`faculty_id`='{$faculty_id}'")); switch ($existing_ids) { case 0: return $faculty_id; break; default: generate_faculty_id(); } }