File "dashboard.php"
Full Path: /home/scheduling/public_html/faculty/dashboard.php
File size: 3.32 KB
MIME-type: text/x-php
Charset: utf-8
<?php
// Database connection details
include 'out.php';
include '../include/conn.php';
// Get the teacher's ID or name (this could come from a session, GET parameter, or form)
$teacher_id =
// Days of the week
$daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'];
// Fetch schedule for the teacher for each day
$schedules = [];
foreach ($daysOfWeek as $day) {
$query = "SELECT * FROM schedule WHERE instructor_id = ? AND days = ?";
$stmt = mysqli_prepare($conn, $query);
mysqli_stmt_bind_param($stmt, "is", $teacher_id, $day);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$schedules[$day] = mysqli_fetch_all($result, MYSQLI_ASSOC);
}
mysqli_close($conn); // Close the connection
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Teacher's Weekly Schedule</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- Loader Overlay -->
<div id="loader" class="loader-overlay">
<div class="spinner-border" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<div class="d-flex">
<?php include("sidebar.php"); ?>
<!-- Main Content -->
<div class="w-100">
<!-- Navbar -->
<?php include("nav.php"); ?>
<!-- Dashboard Content -->
<div class="content mt-5">
<div class="container-fluid">
<h2 class="mb-4">Weekly Schedule (Monday to Friday)</h2>
<?php foreach ($daysOfWeek as $day): ?>
<div class="mb-5">
<h4><?php echo $day; ?></h4>
<?php if (!empty($schedules[$day])): ?>
<table class="table table-bordered">
<thead>
<tr>
<th>Start Time</th>
<th>End Time</th>
<th>Subject</th>
<th>Room</th>
</tr>
</thead>
<tbody>
<?php foreach ($schedules[$day] as $schedule): ?>
<tr>
<!-- Convert time to 12-hour format with AM/PM -->
<td><?php echo date("g:i A", strtotime($schedule['start_time'])); ?></td>
<td><?php echo date("g:i A", strtotime($schedule['end_time'])); ?></td>
<td><?php echo htmlspecialchars($schedule['subject_name']); ?></td>
<td><?php echo htmlspecialchars($schedule['room']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<p>No schedule available for <?php echo $day; ?>.</p>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script src="javascript.js"></script>
</body>
</html>