From 420d68c52a3f480f6f73ca9e67494daebaf4b40d Mon Sep 17 00:00:00 2001 From: Fabian Schieder Date: Tue, 31 Mar 2026 00:37:04 +0200 Subject: [PATCH] Add minimum price display to advertisement recommendations in ad_recommendation.php --- ad_recommendation.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/ad_recommendation.php b/ad_recommendation.php index 3726284..715a7bd 100644 --- a/ad_recommendation.php +++ b/ad_recommendation.php @@ -4,8 +4,10 @@ require_once __DIR__ . '/lib/bootstrap.php'; $conn = db_connect(); $stmt = $conn->query(" - SELECT productID, model, description, imagePath - FROM products + SELECT p.productID, p.model, p.description, p.imagePath, MIN(o.price) as minPrice + FROM products p + LEFT JOIN offers o ON p.productID = o.productID + GROUP BY p.productID ORDER BY RAND() LIMIT 1 "); @@ -16,6 +18,8 @@ if ($stmt && $stmt->num_rows > 0) { $rModel = htmlspecialchars($randomProduct['model'] ?? ''); $rDesc = htmlspecialchars($randomProduct['description'] ?? ''); $rImg = htmlspecialchars($randomProduct['imagePath'] ?? 'assets/images/placeholder.png'); + $rPriceRaw = $randomProduct['minPrice']; + $rPriceFormatted = $rPriceRaw ? number_format((float)$rPriceRaw, 2, ',', '.') : '100,00'; ?>