-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudent_info.php
88 lines (82 loc) · 3.17 KB
/
student_info.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
<?php
session_start();
include('db.php');
if (!isset($_SESSION['User_id']) || $_SESSION['user_role'] !== 'admin') {
header("Location: login.php");
exit;
}
$query = "SELECT s.student_id, s.name, d.department_name, s.section, s.admission_year, s.semester
FROM students AS s
JOIN department AS d ON s.department_id = d.department_id;";
// change the query, few attributes are changed in the database
//done
$result = mysqli_query($connection, $query);
$students_data = mysqli_fetch_all($result, MYSQLI_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Info</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
</style>
</head>
<body>
<div class="container">
<h2 class="text-center my-4">Student Information</h2>
<button onclick="goBack()" class="btn btn-secondary mb-3">Go Back</button>
<table>
<thead>
<tr>
<th>id</th>
<th>Name</th>
<th>Department</th>
<th>Section</th>
<th>Admission year</th>
<th>current sem</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($students_data as $student): ?>
<tr>
<td><?php echo htmlspecialchars($student['student_id']); ?></td>
<td><?php echo htmlspecialchars($student['name']); ?></td>
<td><?php echo htmlspecialchars($student['department_name']); ?></td>
<td><?php echo htmlspecialchars($student['section']); ?></td>
<td><?php echo htmlspecialchars($student['admission_year']); ?></td>
<td><?php echo htmlspecialchars($student['semester']); ?></td>
<td>
<form method="post" action="edit_student.php">
<input type="hidden" name="id" value="<?php echo $student['id']; ?>">
<button type="submit" class="btn btn-sm btn-primary">Edit</button>
</form>
<!-- student id is getting passed as parameter to edit_student.php -->
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<button onclick="goBack()" class="btn btn-secondary mb-3">Go Back</button>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
<script>
function goBack() {
window.history.back();
}
</script>
</body>
</html>