-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.php
89 lines (82 loc) · 2.32 KB
/
view.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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "formdata3";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM data";
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<html>
<head>
<title>View Data</title>
<link rel="stylesheet" href="styles.css">
<style>
table,th,td{
border: 1px solid red;
padding: 10px;
}
body{
background-color: rgb(155, 255, 68);
color:red;
}
.container{
width: 700px;
margin: 50px auto;
}
.btn{
padding: 5px;
background-color: red;
color: rgb(155, 255, 68);
text-decoration: none;
}
.btn-margin{
display : inline-block;
margin-bottom: 15px;
}
</style>
</head>
<body>
<div class='container'>
<table border="1" style='border-collapse: collapse;'>
<tr>
<!-- <th>ID</th> -->
<th>Image</th>
<th>Name</th>
<th>Email</th>
<th>Country</th>
<th>Gender</th>
<th>Action</th>
</tr>
<?php
if ($result->num_rows > 0) {
foreach ($result as $key => $row) {
echo "<tr>";
// echo "<td>" . $row["id"] . "</td>";
echo "<td>". "<img src='uploads/".$row['filename']."' width='auto' height='150'>". "</td>";
echo "<td>" . $row["name"] . "</td>";
echo "<td>" . $row["email"] . "</td>";
echo "<td>" . $row["country"] . "</td>";
echo "<td>" . $row["gender"] . "</td>";
echo "<td>
<a class='btn btn-margin' href='update.php?id=" . $row["id"] . "'>Update</a>
<a class='btn' href='delete.php?id=" . $row["id"] . "'>Delete</a>
</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='4'>No records found</td></tr>";
}
$conn->close();
?>
</table>
</br>
<a href="index.html" class='btn'>Back to Form</a></div>
</body>
</html>