-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewer.php
92 lines (81 loc) · 2.33 KB
/
viewer.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<?php
include('components/header.inc.php');
?>
<nav class="navbar navbar-light bg-light">
<a class="navbar-brand" href="index.php">Input student details</a>
</nav>
<?php
$conn = mysqli_connect("localhost", "root", "kca");
if (!$conn) {
echo "<p class='text-center text-red m-0'>Connection failed.</p>";
} else {
echo "<p class='text-center text-green m-0'>Connection successful.</p>";
}
mysqli_select_db($conn,'kca');
// if($_SERVER['REQUEST_METHOD'] === 'GET'){
$selector = "SELECT * FROM students";
$result = mysqli_query($conn, $selector);
if ($result) {
echo "<p class='text-center text-green m-0'>Data retrieved successfully</p>";
} else {
echo "<p class='text-center text-red m-0'>Error: " . mysqli_error($connection) . "</p>";
}
// }
?>
<table class="table">
<thead class="thead-light">
<tr>
<th scope="col">Reg No.</th>
<th scope="col">First Name</th>
<th scope="col">Middle Name</th>
<th scope="col">Surname</th>
<th scope="col">Age</th>
<th scope="col">Phone</th>
<th scope="col">Course</th>
<th scope="col">Guardian</th>
</tr>
</thead>
<tbody>
<?php
if($result){
while($row = mysqli_fetch_array($result)){
echo "<tr>
<th scope = 'row>{$row['regno']}</th>
<td>{$row['fname']}</td>
<td>{$row['mname']}</td>
<td>{$row['sname']}</td>
<td>{$row['age']}</td>
<td>{$row['tel']}</td>
<td>{$row['course']}</td>
<td>{$row['guardian']}</td>
</tr>";
}
}
?>
</tbody>
</table>
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img src="..." class="rounded mr-2" alt="...">
<strong class="mr-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
<?php
mysqli_close($conn)
?>
</body>
</html>