-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
76 lines (64 loc) · 2.33 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Shop</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container my-5">
<h2>List Of Clients</h2>
<a class="btn btn-primary" type="button" href="/myshop/create.php">New Client</a>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th>Address</th>
<th>Created At</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "myshop";
//connect
$connection = new mysqli ($servername, $username, $password, $database);
//check connection
if ($connection -> connect_error) {
die("Connection failed: " . $connection -> connect_error);
}
$sql = "SELECT * FROM clients";
$result = $connection -> query($sql);
if (!$result) {
die("invalid query: " . $connection -> error);
}
while ($row = $result -> fetch_assoc()){
echo"
<tr>
<td>$row[id]</td>
<td>$row[name]</td>
<td>$row[email]</td>
<td>$row[phone]</td>
<td>$row[address]</td>
<td>$row[created_at]</td>
<td>
<a class='btn btn-primary btn-sm' href='/myshop/edit.php?id=$row[id]'>edit</a>
<a class='btn btn-danger btn-sm' href='/myshop/delete.php?id=$row[id]'>delete</a>
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</body>
</html>