-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.php
246 lines (217 loc) · 10.5 KB
/
manage.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
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!DOCTYPE html>
<html>
<head>
<title>Admin Management Panel</title>
<link rel="stylesheet" type="text/css" href="styles_manage.css">
</head>
<body>
<h1>Admin Management Panel</h1>
<!-- Tabbed navigation -->
<div class="tab">
<button class="tablinks" onclick="openTab(event, 'studentsTab')">Students</button>
<button class="tablinks" onclick="openTab(event, 'teachersTab')">Teachers</button>
<button class="tablinks" onclick="openTab(event, 'coursesTab')">Courses</button>
</div>
<!-- Students Tab -->
<div id="studentsTab" class="tabcontent">
<h2>Manage Students</h2>
<br>
<input type="text" id="studentSearchInput" oninput="searchStudents()" placeholder="Search for students...">
<button class="searchButton" onclick="searchStudents()">Search</button>
<table>
<tbody>
<?php
include('db.php');
// Fetch student data along with their approved courses from the database
$query = "SELECT s.roll_number, s.student_name, s.department, ac.course_name FROM students s
LEFT JOIN approved_courses ac ON s.roll_number = ac.student_roll_number";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
echo '<table>';
echo '<tr><th>Roll Number</th><th>Name</th><th>Department</th><th>Approved Course</th><th>Action</th></tr>';
while ($row = mysqli_fetch_assoc($result)) {
echo '<tr>';
echo '<td>' . $row['roll_number'] . '</td>';
echo '<td>' . $row['student_name'] . '</td>';
echo '<td>' . $row['department'] . '</td>';
echo '<td>' . $row['course_name'] . '</td>';
echo '<td><a href="delete_student.php?roll_number=' . $row['roll_number'] . '&course_name=' . $row['course_name'] . '">Delete</a></td>';
echo '</tr>';
}
echo '</table>';
} else {
echo 'No students found.';
}
?>
</tbody>
</table>
</div>
<br>
<!-- Teachers Tab -->
<div id="teachersTab" class="tabcontent">
<h2>Manage Teachers</h2>
<br>
<input type="text" id="teacherSearchInput" oninput="searchTeachers()" placeholder="Search for teachers...">
<button class="searchButton" onclick="searchTeachers()">Search</button>
<table>
<tbody>
<?php
include('db.php');
// Fetch teacher data along with their courses and departments from the database
$query = "SELECT i.teacher_id, i.teacher_name, i.department, c.course_name
FROM instructors i
LEFT JOIN courses_instructors ci ON i.teacher_id = ci.teacher_id
LEFT JOIN courses c ON ci.course_id = c.course_id";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
echo '<table>';
echo '<tr><th>Teacher ID</th><th>Name</th><th>Department</th><th>Course</th><th>Action</th></tr>';
while ($row = mysqli_fetch_assoc($result)) {
echo '<tr>';
echo '<td>' . $row['teacher_id'] . '</td>';
echo '<td>' . $row['teacher_name'] . '</td>';
echo '<td>' . $row['department'] . '</td>';
echo '<td>' . $row['course_name'] . '</td>';
echo '<td><a href="delete_teacher.php?teacher_id=' . $row['teacher_id'] . '&course_name=' . $row['course_name'] . '">Delete</a></td>';
echo '</tr>';
}
echo '</table>';
} else {
echo 'No teachers found.';
}
?>
</tbody>
</table>
</div>
<!-- Courses Tab -->
<div id="coursesTab" class="tabcontent">
<h2>Manage Courses</h2>
<br>
<input type="text" id="courseSearchInput" oninput="searchCourses()" placeholder="Search for courses...">
<button class="searchButton" onclick="searchCourses()">Search</button>
<table>
<tbody>
<?php
include('db.php');
// Fetch course data along with the count of students enrolled in each course
$query = "SELECT c.course_id, c.course_name, c.course_code, c.department, COUNT(ac.student_roll_number) AS student_count
FROM courses c
LEFT JOIN approved_courses ac ON c.course_name = ac.course_name
GROUP BY c.course_id, c.course_name, c.course_code, c.department";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
echo '<table>';
echo '<tr><th>Course Name</th><th>Course Code</th><th>Department</th><th>Student Count</th><th>Action</th></tr>';
while ($row = mysqli_fetch_assoc($result)) {
echo '<tr>';
echo '<td>' . $row['course_name'] . '</td>';
echo '<td>' . $row['course_code'] . '</td>';
echo '<td>' . $row['department'] . '</td>';
echo '<td>' . $row['student_count'] . '</td>';
echo '<td><a href="delete_course.php?course_name=' . $row['course_name'] . '">Delete</a></td>';
echo '</tr>';
}
echo '</table>';
} else {
echo 'No courses found.';
}
?>
</tbody>
</table>
</div>
<script>
// JavaScript function to switch tabs
function openTab(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
function searchStudents() {
// Get the input value for searching
var searchInput = document.getElementById("studentSearchInput").value.toLowerCase();
// Get all the rows in the table
var rows = document.querySelectorAll("#studentsTab table tbody tr");
// Loop through each row and hide/show based on the search input
for (var i = 0; i < rows.length; i++) {
var cells = rows[i].getElementsByTagName("td");
if (cells.length >= 4) {
var rollNumber = cells[0].textContent.toLowerCase();
var name = cells[1].textContent.toLowerCase();
var department = cells[2].textContent.toLowerCase();
var course = cells[3].textContent.toLowerCase();
if (
rollNumber.includes(searchInput) ||
name.includes(searchInput) ||
department.includes(searchInput) ||
course.includes(searchInput)
) {
rows[i].style.display = ""; // Show the row
} else {
rows[i].style.display = "none"; // Hide the row
}
}
}
}
function searchTeachers() {
// Get the input value for searching
var searchInput = document.getElementById("teacherSearchInput").value.toLowerCase();
// Get all the rows in the table
var rows = document.querySelectorAll("#teachersTab table tbody tr");
// Loop through each row and hide/show based on the search input
for (var i = 0; i < rows.length; i++) {
var cells = rows[i].getElementsByTagName("td");
if (cells.length >= 4) {
var teacherId = cells[0].textContent.toLowerCase();
var teacherName = cells[1].textContent.toLowerCase();
var department = cells[2].textContent.toLowerCase();
var course = cells[3].textContent.toLowerCase();
if (
teacherId.includes(searchInput) ||
teacherName.includes(searchInput) ||
department.includes(searchInput) ||
course.includes(searchInput)
) {
rows[i].style.display = ""; // Show the row
} else {
rows[i].style.display = "none"; // Hide the row
}
}
}
}
function searchCourses() {
// Get the input value for searching
var searchInput = document.getElementById("courseSearchInput").value.toLowerCase();
// Get all the rows in the table
var rows = document.querySelectorAll("#coursesTab table tbody tr");
// Loop through each row and hide/show based on the search input
for (var i = 0; i < rows.length; i++) {
var cells = rows[i].getElementsByTagName("td");
if (cells.length >= 4) {
var courseName = cells[0].textContent.toLowerCase();
var courseCode = cells[1].textContent.toLowerCase();
var department = cells[2].textContent.toLowerCase();
var studentCount = cells[3].textContent.toLowerCase();
if (
courseName.includes(searchInput) ||
courseCode.includes(searchInput) ||
department.includes(searchInput) ||
studentCount.includes(searchInput)
) {
rows[i].style.display = ""; // Show the row
} else {
rows[i].style.display = "none"; // Hide the row
}
}
}
}
</script>
</body>
</html>