/home/techb158/workloadmatch.com/workloadmatch.com/BackUp/Manager
Edit: /home/techb158/workloadmatch.com/workloadmatch.com/BackUp/Manager/fetch_teachers_for_group.php (3170B)
prepare($query1);
$stmt1->bind_param("ii", $Program_ID, $Group_ID);
$stmt1->execute();
$result1 = $stmt1->get_result();
while ($row = $result1->fetch_assoc()) {
$teachers[$row['Teacher_ID']] = $row;
}
$stmt1->close();
// --- 2. Replacement Teachers ---
$query2 = "
SELECT DISTINCT tp.Teacher_ID, tp.First_Name, tp.Last_Name
FROM teacher_replacement_assignments tra
JOIN teacher_profile tp ON tp.Teacher_ID = tra.Replacing_Teacher_ID
JOIN course_group_schedule_main cgs ON tra.Schedule_ID = cgs.Schedule_ID
WHERE cgs.Program_ID = ? AND cgs.Group_ID = ?
";
$stmt2 = $mysqli->prepare($query2);
$stmt2->bind_param("ii", $Program_ID, $Group_ID);
$stmt2->execute();
$result2 = $stmt2->get_result();
while ($row = $result2->fetch_assoc()) {
$teachers[$row['Teacher_ID']] = $row; // merge with previous by ID
}
$stmt2->close();
// --- 3. Build and return options ---
$options = '
';
foreach ($teachers as $teacher) {
$fullName = htmlspecialchars($teacher['First_Name'] . ' ' . $teacher['Last_Name']);
$options .= "
";
}
echo $options;
}
/*
include_once '../includes/db_connect.php';
include_once '../includes/functions.php';
sec_session_start();
if (isset($_POST['Program_ID']) && isset($_POST['Group_ID'])) {
$Program_ID = intval($_POST['Program_ID']);
$Group_ID = intval($_POST['Group_ID']);
// Retrieve distinct Teacher_IDs from teacher_course_assignments that match the Program and Group,
// then join with teacher_profile to get teacher names.
$query = "
SELECT DISTINCT tca.Teacher_ID, tp.First_Name, tp.Last_Name
FROM teacher_course_assignments tca
JOIN teacher_profile tp ON tca.Teacher_ID = tp.Teacher_ID
WHERE tca.Program_ID = ? AND tca.Group_ID = ?
ORDER BY tp.First_Name ASC
";
$stmt = $mysqli->prepare($query);
if (!$stmt) {
die("Error preparing query: " . $mysqli->error);
}
$stmt->bind_param("ii", $Program_ID, $Group_ID);
$stmt->execute();
$result = $stmt->get_result();
$options = '
';
while ($row = $result->fetch_assoc()) {
$teacherName = htmlspecialchars($row['First_Name'] . ' ' . $row['Last_Name']);
$options .= "
";
}
echo $options;
$stmt->close();
}
*/
?>