prepare('SELECT * FROM manager_group_name WHERE Manager_ID = ? AND Group_ID = ?');
$stmt->bind_param('ss', $decrypted_Cleint_ID, $decrypted_Group_ID);
$stmt->execute();
$result = $stmt->get_result();
$count = $result->num_rows;
$row = $result->fetch_assoc();
$Group_ID = $row["Group_ID"];
$Program_ID = $row["Program_ID"];
$Group_Name = $row["Group_Name"];
$Group_Year = $row["Group_Year"];
$Time_Slot = $row["Time_Slot"];
$Weekend_Class = $row["Weekend_Class"];
if (!empty($Time_Slot)) {
// Convert comma-separated Time_Slot string into an array
$myArrays = explode(',', $Time_Slot);
// Ensure selected time slots are properly formatted for SQL query
$selected_slots = "'" . implode("','", $myArrays) . "'"; // Quote each value
echo $selected_slots; // Debugging output
// Fetch the earliest and latest times for the selected slots
$query = "SELECT MIN(Time_From) AS Earliest_Time, MAX(Time_To) AS Latest_Time FROM time_slot_programs WHERE Time_Slot IN ($selected_slots)";
$result = $mysqli->query($query);
if ($result && $result->num_rows > 0) {
$row = $result->fetch_assoc();
$Time_From = date("H:i", strtotime($row['Earliest_Time'])); // Convert to 24-hour format
$Time_To = date("H:i", strtotime($row['Latest_Time'])); // Convert to 24-hour format
} else {
$Time_From = "";
$Time_To = "";
}
} else {
$Time_From = "";
$Time_To = "";
}
//$Time_From = $row["Time_From"];
//$Time_To = $row["Time_To"];
}else{
set_flash_msg('The group you are trying to open is not exit!', 'warning');
header('Location: addgroup.php');
exit();
}
?>