<?
php
$conn = new mysqli("localhost", "root", "", "ecommerceDB_2021WC86737");
if ($conn->connect_error) die("Connection failed: " . $conn->connect_error);
$result = $conn->query("
SELECT p.product_id, p.product_name, [Link], c.category_name, p.unit_price,
[Link], [Link]
FROM products p
LEFT JOIN categories c ON p.category_id = c.category_id
ORDER BY p.product_id ASC
");
?>
<h2>Product List</h2>
<table border="1" cellpadding="5" cellspacing="0">
<tr>
<th>ID</th>
<th>Name</th>
<th>SKU</th>
<th>Category</th>
<th>Price</th>
<th>Quantity</th>
<th>Description</th>
<th>Actions</th>
</tr>
<?php
while ($row = $result->fetch_assoc()) {
echo "<tr>
<td>{$row['product_id']}</td>
<td>{$row['product_name']}</td>
<td>{$row['sku']}</td>
<td>{$row['category_name']}</td>
<td>{$row['unit_price']}</td>
<td>{$row['quantity']}</td>
<td>{$row['description']}</td>
<td>
<a href='product_crud.php?edit={$row['product_id']}'>Edit</a> |
<a href='product_crud.php?delete={$row['product_id']}' onclick=\"return
confirm('Delete this product?')\">Delete</a>
</td>
</tr>";
}
$conn->close();
?>
</table>