-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_products.php
37 lines (34 loc) · 1005 Bytes
/
fetch_products.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
<?php
include('db_config.php');
$sql = "SELECT * FROM products";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo '<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Description</th>
<th>Price</th>
<th>Action</th>
</tr>
</thead>
<tbody>';
while ($row = $result->fetch_assoc()) {
echo '<tr>
<td>' . $row['id'] . '</td>
<td>' . $row['name'] . '</td>
<td>' . $row['description'] . '</td>
<td>' . $row['price'] . '</td>
<td>
<button type="button" class="btn btn-danger delete-btn" data-id="' . $row['id'] . '">Delete</button>
<button type="button" class="btn btn-primary edit-btn" data-id="' . $row['id'] . '">Edit</button>
</td>
</tr>';
}
echo '</tbody></table>';
} else {
echo '<p>No products found.</p>';
}
$conn->close();
?>