37035-vm/products.php
Flatlogic Bot 6872ff9a04 first
2025-12-18 12:41:47 +00:00

36 lines
1.5 KiB
PHP

<?php
require_once 'includes/Database.php';
$db = new Database();
$products = $db->query("SELECT p.id, p.name, p.description, p.price, t.name as translated_name, t.description as translated_description FROM products p LEFT JOIN translations t ON p.id = t.product_id AND t.language_code = 'en'");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Products</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h1>Our Products</h1>
<div class="row">
<?php foreach ($products as $product): ?>
<div class="col-md-4 mb-4">
<div class="card">
<div class="card-body">
<h5 class="card-title"><?php echo htmlspecialchars($product['translated_name'] ?: $product['name']); ?></h5>
<p class="card-text"><?php echo htmlspecialchars($product['translated_description'] ?: $product['description']); ?></p>
<p class="card-text"><strong>Price: $<?php echo htmlspecialchars($product['price']); ?></strong></p>
<a href="checkout.php?product_id=<?php echo $product['id']; ?>" class="btn btn-primary">Buy Now</a>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</body>
</html>