-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin_teacher_details.php
106 lines (82 loc) · 2.94 KB
/
admin_teacher_details.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
<?php
session_start();
require_once "assets/connect/pdo.php";
if (!isset($_SESSION['Admin_ID'])) {
header("Location: admin_login.php");
return;
}
$error = '';
$no_data = '';
//deleting record
if (isset($_POST['delete'])) {
$id_to_delete = $_POST['id_to_delete'];
$sql = "DELETE FROM Teacher WHERE Teacher_ID = $id_to_delete";
$stmt = $pdo->prepare($sql);
$stmt = $pdo->query($sql);
if ($stmt) {
header('Location: admin_teacher_info.php');
} else {
$error = '<label class="alert alert-danger">Something went wrong.</label>';
}
}
//getting the data by query parameter
if (isset($_GET['id'])) {
$id = $_GET['id'];
$stmt = $pdo->query("SELECT * from teacher WHERE Teacher_ID = $id");
$infos = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else {
$no_data = '<h5 class="alert alert-danger">No data available.</h5>';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php
//Head Links
require_once 'assets/connect/head.php';
?>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-light sticky-top">
<div class="container justify-content-start">
<a class="navbar-brand" href="index.php"><img id="logo" src="assets/images/LuExamHiveLogo.png" height="30px"> LU EXAM HIVE</a>
<a type="button" href="admin_teacher_info.php" class="btn btn-sm btn-outline-dark ml-3"><i class="fas fa-arrow-left"></i> Go Back</a>
</div>
</nav>
</header>
<main>
<div class="container">
<div class="row mt-4">
<div class="col">
<h3 class="display-4">Teacher Details</h3>
</div>
</div>
<div class="row alert alert-light shadow-lg p-3 mb-5 bg-white rounded mt-3">
<div class="col"></div>
<div class="col-xl-9 col-lg-9 col-md-10 col-sm-9 col-xs-6 my-5">
<?php foreach ($infos as $info) {?>
<p><b>Teacher ID: </b><span class="text-primary"><?php echo $info['Teacher_ID']; ?></span></p>
<p><b>Name: </b><span class="text-primary"><?php echo $info['Name']; ?></span></p>
<p><b>Department: </b><span class="text-primary"><?php echo $info['Department']; ?></span></p>
<p><b>Email: </b><span class="text-primary"><?php echo $info['Teacher_Email']; ?></span></p>
<p><b>Registration Date & Time: </b><span class="text-primary"><?php echo $info['Registration_Datetime']; ?></span></p>
<!-- Delete Button -->
<form action="admin_teacher_details.php" method="POST" class="d-flex justify-content-end">
<input type="hidden" name="id_to_delete" value="<?php echo $info['Teacher_ID'] ?>">
<input type="submit" name="delete" value="Delete record" class="btn btn-danger mt-5">
</form>
<?php }?>
<?php echo $no_data; ?>
</div>
<div class="col"></div>
</div>
</div>
</main>
<!--footer Start -->
<?php
require_once 'assets/connect/footer.php';
?>
<!--footer End -->
</body>
</html>