query("SELECT * FROM classes WHERE id=$class_id")->fetch_assoc(); $days = ["Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"]; $hours = [ 1 => "Prima ora
7:50 - 8:50", 2 => "Seconda ora
8:50 - 9:45", 3 => "Terza ora
9:55 - 10:50", 4 => "Quarta ora
10:50 - 11:45", 5 => "Quinta ora
11:55 - 12:50", 6 => "Sesta ora
12:50 - 13:50" ]; // FIX: Validazione classe prima di tutto if (!isset($_GET['class_id'])) { header("Location: index.php"); exit; } $class_id = intval($_GET['class_id']); $res = $conn->query("SELECT id FROM classes WHERE id = $class_id LIMIT 1"); if ($res->num_rows === 0) { header("Location: index.php"); exit; } ?> Orario <?php echo htmlspecialchars($class['name']); ?>

Orario della classe

$d"; ?> $hlabel){ echo ""; foreach($days as $d){ $q = $conn->query("SELECT subjects.name, subjects.teacher, subjects.room FROM timetable LEFT JOIN subjects ON timetable.subject_id = subjects.id WHERE class_id=$class_id AND day='$d' AND hour=$hnum"); if($q->num_rows > 0){ // FIX: Gestione corretta di multipli docenti/materie $entries = []; $subject = null; $room = null; while($row = $q->fetch_assoc()){ if($subject === null) { $subject = $row['name']; $room = $row['room']; } $entries[] = $row['teacher']; } // Unisci i docenti correttamente if(count($entries) > 1){ $last = array_pop($entries); $teachers_list = implode(", ", $entries) . " e " . $last; } else { $teachers_list = $entries[0]; } echo ""; } else { echo ""; } } echo ""; } ?>
$hlabel
" . htmlspecialchars($subject) . "
" . htmlspecialchars($teachers_list) . "
"; if(!empty($room)) { echo "
" . htmlspecialchars($room) . "
"; } echo "

$hlabel): $q = $conn->query("SELECT subjects.name, subjects.teacher, subjects.room FROM timetable LEFT JOIN subjects ON timetable.subject_id = subjects.id WHERE class_id=$class_id AND day='$d' AND hour=$hnum"); if($q->num_rows > 0): // FIX: Stessa logica corretta anche per mobile $entries = []; $subject = null; $room = null; while($row = $q->fetch_assoc()){ if($subject === null) { $subject = $row['name']; $room = $row['room']; } $entries[] = $row['teacher']; } if(count($entries) > 1){ $last = array_pop($entries); $teachers_list = implode(", ", $entries) . " e " . $last; } else { $teachers_list = $entries[0]; } ?>

Copyright (C) 2025 EmmeV. - Released under GNU AGPL 3.0 License.