-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_students.php
107 lines (94 loc) · 2.82 KB
/
view_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
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
<?php
// Start a session
session_start();
// Check if the user is not logged in or is not an admin
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
// Redirect to the login page or access denied page
header('Location: index.php');
exit();
}
// Include the db_connection.php file
require_once 'db_connection.php';
// Retrieve the student details from the database
$stmt = $mysqli->prepare('SELECT * FROM students');
$stmt->execute();
$result = $stmt->get_result();
$students = $result->fetch_all(MYSQLI_ASSOC);
// Close the statement
$stmt->close();
?>
<!DOCTYPE html>
<html>
<head>
<title>View Students</title>
<style>
body {
background-color: #f8f9fa;
font-family: Arial, sans-serif;
padding: 20px;
}
h1 {
color: #333;
text-align: center;
margin-bottom: 20px;
}
table {
width: 100%;
border-collapse: collapse;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
th,
td {
padding: 10px;
text-align: left;
border-bottom: 1px solid #ccc;
}
th {
background-color: #007bff;
color: #fff;
}
td {
color: #333;
}
a {
color: #007bff;
text-decoration: none;
margin-right: 10px;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>View Students</h1>
<table>
<tr>
<th>Student ID</th>
<th>Student Name</th>
<th>Student Email</th>
<th>Student Phone</th>
<th>Date of Birth</th>
<th>Address</th>
<th>Action</th>
</tr>
<?php foreach ($students as $student) { ?>
<tr>
<td><?php echo $student['student_id']; ?></td>
<td><?php echo $student['student_name']; ?></td>
<td><?php echo $student['student_email']; ?></td>
<td><?php echo $student['student_phone']; ?></td>
<td><?php echo $student['date_of_birth']; ?></td>
<td><?php echo $student['address']; ?></td>
<td>
<a href="edit_student.php?id=<?php echo $student['student_id']; ?>">Edit</a>
<a href="delete_student.php?id=<?php echo $student['student_id']; ?>" onclick="return confirm('Are you sure you want to delete this student?')">Delete</a>
</td>
</tr>
<?php } ?>
</table>
</body>
</html>