33828-dev/students.php
Flatlogic Bot 5926dbfc54 main part
2025-09-02 19:37:21 +00:00

70 lines
2.4 KiB
PHP

<?php include 'header.php'; ?>
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Students</h1>
<button class="btn btn-primary" data-toggle="modal" data-target="#addStudentModal"><i class="fas fa-plus"></i> Add New Student</button>
</div>
<?php
$students_json = file_get_contents('data/students.json');
$students = json_decode($students_json, true);
?>
<div class="card">
<div class="card-body">
<table class="table table-striped table-hover">
<thead class="thead-dark">
<tr>
<th>Student Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<?php if (!empty($students)):
foreach ($students as $student):
?>
<tr>
<td><?= htmlspecialchars($student['name']) ?></td>
<td><?= htmlspecialchars($student['email']) ?></td>
</tr>
<?php
endforeach;
else:
?>
<tr>
<td colspan="2">No students found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<!-- Add Student Modal -->
<div class="modal fade" id="addStudentModal" tabindex="-1" aria-labelledby="addStudentModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addStudentModalLabel">Add a new student</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form action="add_student.php" method="post">
<div class="form-group">
<label for="name">Student Name</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<button type="submit" class="btn btn-primary">Add Student</button>
</form>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>