-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewstudents.php
79 lines (69 loc) · 2.15 KB
/
viewstudents.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
<?php
require 'includes/snippet.php';
require 'includes/db-inc.php';
include "includes/header.php";
include "includes/nav.php";
if (isset($_POST['submit'])) {
$id = trim($_POST['del_btn']);
$sql = "DELETE from students where studentId = '$id'";
$query = mysqli_query($conn, $sql);
if ($query) {
echo "<script>alert('Student Deleted!')</script>";
}
}
?>
<div class="container">
<!-- navbar ends -->
<!-- info alert -->
<div class="alert alert-warning col-lg-7 col-md-12 col-sm-12 col-xs-12 col-lg-offset-2 col-md-offset-0 col-sm-offset-1 col-xs-offset-0" style="margin-top:70px">
<span class="glyphicon glyphicon-book"></span>
<strong>Student</strong> Table
</div>
</div>
<div class="container col-lg-11 ">
<div class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading">
<div class="row">
<a href="addstudent.php"><button class="btn btn-success col-lg-3 col-md-4 col-sm-11 col-xs-11 button" style="margin-left: 15px;margin-bottom: 5px"><span class="glyphicon glyphicon-plus-sign"></span> Add Student</button></a>
</div>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>ID No</th>
<th>Name</th>
<th>Email</th>
<th>Department</th>
<th>Phone No.</th>
<th>REMOVE</th>
</tr>
</thead>
<?php
$sql = "SELECT * FROM students";
$query = mysqli_query($conn, $sql);
$counter = 1;
while ( $row = mysqli_fetch_assoc($query)) {
?>
<tbody>
<tr>
<td><?php echo $counter++; ?></td>
<td><?php echo $row['studentId']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['dept']; ?></td>
<td><?php echo $row['phoneNumber']; ?></td>
<td>
<form action="viewstudents.php" method="post">
<input type="hidden" value="<?php echo $row['studentId']; ?>" name="del_btn">
<button name="submit" class="btn btn-warning">DELETE</button>
</form>
</td>
</tr>
</tbody>
<?php } ?>
</table>
</div>
</div>
<?php include 'includes/footer.php'; ?>