-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbanned-student.php
129 lines (117 loc) · 3.46 KB
/
banned-student.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php include 'teachers-dashboard-header.php'; ?>
<div class="toggle">
<input type="checkbox" id="toggle" />
<label for="toggle"></label>
<em>Enable dark mode!</em>
</div>
<script>
const toggle = document.getElementById('toggle');
const body = document.body;
toggle.addEventListener('input', e => {
const isChecked = e.target.checked;
if (isChecked) {
body.classList.add('dark-theme');
} else {
body.classList.remove('dark-theme');
}
});
</script>
<h4>Banned Students' Data</h4>
<br><br>
<div class="col-lg-12" style="padding-top: 10px" class="panel panel-primary">
<!-- Algorithm to ban, pardon and expell -->
<?php
if (isset($_GET['ban'])){
$id = preg_replace('/[^-a-zA-Z0-9_]/', '', $_GET['ban']);
$ban = $student->banStudent($id);
}
if (isset($_GET['pardon'])){
$id = preg_replace('/[^-a-zA-Z0-9_]/', '', $_GET['pardon']);
$pardon = $student->pardonStudent($id);
}
if (isset($_GET['expell'])){
$id = preg_replace('/[^-a-zA-Z0-9_]/', '', $_GET['expell']);
$expell = $student->expellStudent($id);
}
// display the appropriate success or error messages
if (isset($ban)) {
echo $ban;
}
if (isset($pardon)) {
echo $pardon;
}
if (isset($expell)) {
echo $expell;
}
?>
<!-- Do not tamper with the id of this table -->
<table id="studentTable" class="table table-striped table-bordered" style="width:100%">
<!--Table head-->
<thead>
<tr>
<th>S/N</th>
<th>Name</th>
<th>Email</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<!-- Show all students -->
<?php
$getAllStudents = $student->selectAllStudents();
if ($getAllStudents) {
$i = 0;
while ($result = $getAllStudents->fetch_assoc()) {
$i++;
?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $result['name']; ?></td>
<td><?php echo $result['email']; ?></td>
<td>
<?php
if ($result['status'] == 0) {
echo "Enrolled";
} elseif ($result['status'] == 1) {
echo "<span style='color: red; font-weight: bold;'>Banned</spa>";
} else {
echo "Expelled";
}
?>
</td>
<td>
<!-- ban button -->
<a href="?ban=<?php echo $result["id"]; ?>" type="button" name="expell_student" class="btn btn-primary btn-sm">Ban</a>
<!-- pardon button -->
<a href="?pardon=<?php echo $result["id"]; ?>" type="button" name="expell_student" class="btn btn-info btn-sm">Pardon</a>
<!-- expell button -->
<a href="?expell=<?php echo $result["id"]; ?>" type="button" name="expell_student" class="btn btn-danger btn-sm">Expell</a>
</td>
</tr>
<?php } } ?>
</tbody>
<tfoot>
<tr>
<th>S/N</th>
<th>Name</th>
<th>Email</th>
<th>Status</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
<script src="js/jquery-3.3.1.js"></script>
<script src="js/jquery.dataTables.min.js"></script>
<script src="js/dataTables.bootstrap4.min.js"></script>
<script>
$(document).ready(function() {
$('#studentTable').DataTable( {
scrollY: true,
scrollX: true
});
} );
</script>
</body>
</html>