-
Notifications
You must be signed in to change notification settings - Fork 0
/
students.php
251 lines (127 loc) · 5.23 KB
/
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
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
<?php include_once "app/autoload.php"; ?>
<?php
// Data taking from URL for DELETE button
if ( isset($_GET['delete_id'])) {
$delete_id = $_GET['delete_id'];
$delete_photo = $_GET['delete_photo'];
$sql = "DELETE FROM users WHERE id='$delete_id' ";
$way ->query($sql);
// Photo Delete
unlink('photo/students/' . $delete_photo);
header('location:students.php');
}
// Data taking for URL for ACTIVE , INACTIVE button
// Active user
if ( isset($_GET['active_id'])) {
$active_id = $_GET['active_id'];
$sql = "UPDATE users SET status='agree' WHERE id='$active_id' ";
$way ->query($sql);
header('location:students.php');
}
// Inactive user
if ( isset($_GET['inactive_id'])) {
$inactive_id = $_GET['inactive_id'];
$sql = "UPDATE users SET status='disagree' WHERE id='$inactive_id' ";
$way ->query($sql);
header('location:students.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Class 14</title>
<!-- All CSS Files -->
<link rel="stylesheet" href="assets/fonts/font-awesome/css/all.css">
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<div class="container shadow-lg p-3 mt-5 mb-3">
<div class="students-table mt-5">
<div class="row">
<div class="col-md-12">
<div class="table">
<div class="student-top">
<h2 class="p-3 text-white">All Students</h2>
<a href="profile.php" class="btn p-2 text-white ">Your profile</a>
</div>
<div class="full-table">
<table class="table-striped shadow-lg w-100 text-white mt-0">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">Cell</th>
<th scope="col">Gender</th>
<th scope="col">Location</th>
<th scope="col">Photo</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM users";
$data = $way -> query($sql);
$i = 1;
while ( $all_data = $data -> fetch_assoc() ) :
?>
<tr>
<td scope="row"><?php echo $i++; ?></td>
<td><?php echo $all_data['name']; ?></td>
<td><?php echo $all_data['email']; ?></td>
<td><?php echo $all_data['cell']; ?></td>
<td><?php echo $all_data['gender']; ?></td>
<td><?php echo $all_data['location']; ?></td>
<td>
<?php if($all_data['status']=='agree') : ?>
<img style="border-radius: 50%; border:3px solid green;" src="photo/students/<?php echo $all_data['photo']; ?>" alt="">
<?php elseif($all_data['status']=='disagree') : ?>
<img style="border-radius: 50%; border:3px solid red;" src="photo/students/<?php echo $all_data['photo']; ?>" alt="">
<?php endif; ?>
</td>
<td>
<?php if( $all_data['id'] == $_SESSION['user_id'] ) : ?>
<!-- Active, Inactive -->
<?php if($all_data['status']=='agree') : ?>
<a href="?inactive_id=<?php echo $all_data['id']; ?>" class="btn btn-danger"><i class="far fa-thumbs-down"></i></a>
<?php elseif($all_data['status']=='disagree') : ?>
<a href="?active_id=<?php echo $all_data['id']; ?>" class="btn btn-success"><i class="far fa-thumbs-up"></i></a>
<?php endif; ?>
<!-- Edit -->
<a href="edit.php?edit_id=<?php echo $all_data['id']; ?>" class="btn btn-warning"><i class="far fa-edit"></i></a>
<!-- Delete-->
<a id="alert-msg" href="?delete_id=<?php echo $all_data['id']; ?>&delete_photo=<?php echo $all_data['photo']; ?>" class="btn btn-danger"><i class="fas fa-trash-alt"></i></a>
<?php else :?>
<!-- View -->
<a href="user_profile.php?profile_id=<?php echo $all_data['id']; ?>" class="btn btn-info"><i class="fas fa-eye"></i></a>
<?php endif; ?>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="assets/js/jquery-3.5.1.slim.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script>
// Alert popup system for data Delete
$('#alert-msg').click(function(){
let conf = confirm('Are you sure ?');
if ( conf == true ) {
return true;
}else{
return false;
}
});
</script>
</body>
</html>