-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEmp_retrieve.php
More file actions
154 lines (130 loc) · 3.88 KB
/
Copy pathEmp_retrieve.php
File metadata and controls
154 lines (130 loc) · 3.88 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employee Details</title>
<style>
.tt {
text-align: center;
font-size: 30px;
font-family: 'Times New Roman', Times, serif;
margin: 25px 20px;
}
table {
border-collapse: collapse;
width: 100%;
border: none;
}
th,
td {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
border: none;
}
th {
background-color: #fff;
font-family: 'Times New Roman', Times, serif;
}
tr {
border: 3px solid black;
}
img {
width: 100px;
height: 100px;
object-fit: cover;
border-radius: 50%;
}
.btn {
padding: 5px 10px;
background-color: #f5bf23;
color: #fff;
border: none;
cursor: pointer;
width: 90px;
margin-top: 8px;
border-radius: 10px;
}
.btn:hover {
background-color: #a17a03;
}
.pagination {
text-align: center;
margin-top: 10px;
}
.pagination a:hover {
background-color: #a17a03;
}
.pagination a {
display: inline-block;
margin: 0 5px;
padding: 5px 10px;
background-color: #f5bf23;
color: #fff;
text-decoration: none;
border-radius: 10px;
width: 90px;
}
.del {
background-color: #dc3545;
}
.del:hover {
background-color: #c82333;
}
/* undu onji css file d padla */
</style>
</head>
<body>
<h1 class="tt">Employee Details</h1>
<?php
// Database name change manpu
$conn = mysqli_connect('localhost', 'root', '', 'db_webuild');
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$limit = 3;
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$start = ($page - 1) * $limit;
$sql = "SELECT * FROM Employees LIMIT $start, $limit";
$result = mysqli_query($conn, $sql);
echo "<table>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td><img src='" . $row['image'] . "' alt='" . $row['name'] . "'></td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['role'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "<td>";
echo "<button class='btn' onclick='updateEmployee()'>Update</button>";
echo "<form method='post' action='delete_employee.php'>";
echo "<input type='hidden' name='delete_id' value='" . $row["id"] . "'>";
echo "<button type='submit' class='btn del' onclick='return confirm(\"Are you sure you want to delete this employee?\")'>Delete</button>";
echo "</form>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
$sql_total = "SELECT COUNT(*) AS total FROM Employees";
$result_total = mysqli_query($conn, $sql_total);
$row_total = mysqli_fetch_assoc($result_total);
$total_records = $row_total['total'];
$total_pages = ceil($total_records / $limit);
echo "<div class='pagination'>";
for ($i = 1; $i <= $total_pages; $i++) {
echo "<a href='?page=$i'>$i</a>";
}
echo "</div>";
mysqli_close($conn);
?>
<script>
function deleteEmployee(employeeId) {
if (confirm("Are you sure you want to delete this employee?")) {
window.location.href = "delete_employee.php?id=" + employeeId;
}
}
function updateEmployee() {
}
</script>
</body>
</html>