forked from hung1605/student_manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search_students.php
40 lines (37 loc) · 1.65 KB
/
search_students.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
<?php
// Include necessary files and initialize database connection
session_start();
include 'functions/student_functions.php';
// Check if the search term is provided in the request
if (isset($_GET['search'])) {
// Get the search term from the request
$searchTerm = $_GET['search'];
// Call the function to search for students based on the provided search term
$filteredStudents = searchStudents($searchTerm);
// Check if any students are found
if ($filteredStudents->num_rows > 0) {
// Display the filtered student data
echo "<table><tr><th>ID</th><th>Name</th><th>Class</th><th>DOB</th><th>Address</th><th>Actions</th></tr>";
while ($row = $filteredStudents->fetch_assoc()) {
echo "<tr>
<td>{$row['MaSV']}</td>
<td>{$row['HoTen']}</td>
<td>{$row['MaLop']}</td>
<td>{$row['NgaySinh']}</td>
<td>{$row['DiaChi']}</td>
<td>
<button class=\"btn btn-info\" onclick=\"openPopup('update_student.php?id={$row['MaSV']}')\">Update</button>
<button class=\"btn btn-info\" onclick=\"openPopup('show_gpa.php?id={$row['MaSV']}')\">Xem Điểm</button>
<button class=\"btn btn-danger\" onclick=\"openPopup('delete_student.php?id={$row['MaSV']}')\">Delete</button>
</td>
</tr>";
}
echo "</table>";
} else {
// No students found with the given search term
echo "No students found.";
}
} else {
// No search term provided in the request
echo "No search term provided.";
}