-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent.php
More file actions
211 lines (175 loc) · 5.06 KB
/
Copy pathstudent.php
File metadata and controls
211 lines (175 loc) · 5.06 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php
require_once "admin_middleware.php";
require_once "config.php";
/* -------------------------------------------
FETCH ALL STUDENTS (FULL DATA)
-------------------------------------------- */
$stmt = $pdo->query("
SELECT
s.*,
u.full_name,
u.email,
u.student_id AS user_student_id,
u.reg_number,
d.name AS department_name,
c.title AS course_title,
l.level_name
FROM students s
LEFT JOIN users u ON s.user_id = u.id
LEFT JOIN departments d ON s.department_id = d.id
LEFT JOIN courses c ON s.course_id = c.id
LEFT JOIN levels l ON s.level_id = l.id
ORDER BY u.full_name ASC
");
$students = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin • Students</title>
<style>
body {
font-family: "Segoe UI", Tahoma, Arial, sans-serif;
background: #f4f6f9;
padding: 30px;
}
/* Container */
.card {
background: #fff;
border-radius: 12px;
padding: 24px;
box-shadow: 0 10px 25px rgba(0,0,0,.08);
max-width: 1600px;
margin: auto;
}
/* Header */
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.header h2 {
margin: 0;
color: #1f2937;
}
.search {
padding: 10px 14px;
border-radius: 8px;
border: 1px solid #d1d5db;
width: 260px;
}
/* Table */
table {
width: 100%;
border-collapse: collapse;
}
thead {
background: #f1f5f9;
}
th {
padding: 12px;
font-size: 0.75rem;
text-transform: uppercase;
text-align: left;
color: #475569;
border-bottom: 1px solid #e5e7eb;
}
td {
padding: 12px;
font-size: 0.85rem;
border-bottom: 1px solid #e5e7eb;
color: #111827;
vertical-align: top;
}
tbody tr:hover {
background: #f9fafb;
}
/* Profile image */
.avatar {
width: 38px;
height: 38px;
border-radius: 50%;
object-fit: cover;
border: 1px solid #e5e7eb;
}
.close-btn {
background: #2563eb;
color: #fff;
padding: 10px 14px;
border-radius: 6px;
text-decoration: none;
font-weight: 600;
cursor: pointer;
}
</style>
</head>
<body>
<div class="card">
<div class="header">
<span class="close-btn" title="Close" onclick="window.location='student_dashboard.php'">×</span>
<h2>🎓 Students Management</h2>
<input type="text" id="searchInput" class="search" placeholder="Search students...">
</div>
<table id="studentTable">
<thead>
<tr>
<th>Photo</th>
<th>Full Name</th>
<th>Student ID</th>
<th>Reg No</th>
<th>Department</th>
<th>Course</th>
<th>Level</th>
<th>Email</th>
<th>Phone</th>
<th>Emergency</th>
<th>Address</th>
<th>DOB</th>
</tr>
</thead>
<tbody>
<?php if (empty($students)): ?>
<tr>
<td colspan="12" style="text-align:center;">No students found</td>
</tr>
<?php else: ?>
<?php foreach ($students as $s): ?>
<tr>
<td>
<img
src="uploads/profile_pic/<?= htmlspecialchars($s['profile_pic'] ?? 'default.png') ?>"
class="avatar"
>
</td>
<td><?= htmlspecialchars($s['full_name'] ?? '') ?></td>
<td><?= htmlspecialchars($s['user_student_id'] ?? 'N/A') ?></td>
<td><?= htmlspecialchars($s['reg_number'] ?? 'N/A') ?></td>
<td><?= htmlspecialchars($s['department_name'] ?? 'Not Assigned') ?></td>
<td><?= htmlspecialchars($s['course_title'] ?? 'Not Assigned') ?></td>
<td><?= htmlspecialchars($s['level_name'] ?? 'Not Assigned') ?></td>
<td><?= htmlspecialchars($s['email'] ?? '') ?></td>
<td><?= htmlspecialchars($s['phone'] ?? '') ?></td>
<td><?= htmlspecialchars($s['emergency_phone'] ?? '') ?></td>
<td><?= htmlspecialchars($s['address'] ?? '') ?></td>
<td>
<?= $s['dob'] ? date('M d, Y', strtotime($s['dob'])) : 'N/A' ?>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
<script>
/* 🔍 Search Filter */
document.getElementById('searchInput').addEventListener('keyup', function () {
let value = this.value.toLowerCase();
document.querySelectorAll('#studentTable tbody tr').forEach(row => {
row.style.display = row.innerText.toLowerCase().includes(value) ? '' : 'none';
});
});
</script>
</body>
</html>