Add minimum price display to advertisement recommendations in ad_recommendation.php

This commit is contained in:
Fabian Schieder 2026-03-31 00:37:04 +02:00
parent c10f5f52ed
commit 420d68c52a

View File

@ -4,8 +4,10 @@ require_once __DIR__ . '/lib/bootstrap.php';
$conn = db_connect(); $conn = db_connect();
$stmt = $conn->query(" $stmt = $conn->query("
SELECT productID, model, description, imagePath SELECT p.productID, p.model, p.description, p.imagePath, MIN(o.price) as minPrice
FROM products FROM products p
LEFT JOIN offers o ON p.productID = o.productID
GROUP BY p.productID
ORDER BY RAND() ORDER BY RAND()
LIMIT 1 LIMIT 1
"); ");
@ -16,6 +18,8 @@ if ($stmt && $stmt->num_rows > 0) {
$rModel = htmlspecialchars($randomProduct['model'] ?? ''); $rModel = htmlspecialchars($randomProduct['model'] ?? '');
$rDesc = htmlspecialchars($randomProduct['description'] ?? ''); $rDesc = htmlspecialchars($randomProduct['description'] ?? '');
$rImg = htmlspecialchars($randomProduct['imagePath'] ?? 'assets/images/placeholder.png'); $rImg = htmlspecialchars($randomProduct['imagePath'] ?? 'assets/images/placeholder.png');
$rPriceRaw = $randomProduct['minPrice'];
$rPriceFormatted = $rPriceRaw ? number_format((float)$rPriceRaw, 2, ',', '.') : '100,00';
?> ?>
<style> <style>
/* Catchy Full-Width Recommendation Ad - Fully Embedded */ /* Catchy Full-Width Recommendation Ad - Fully Embedded */
@ -81,11 +85,23 @@ if ($stmt && $stmt->num_rows > 0) {
.ad-recommendation__content h2 { .ad-recommendation__content h2 {
font-size: 3rem; font-size: 3rem;
font-weight: 900; font-weight: 900;
margin-bottom: 1rem; margin-bottom: 0.5rem;
color: #ffffff; color: #ffffff;
text-shadow: 0 4px 10px rgba(0,0,0,0.2); text-shadow: 0 4px 10px rgba(0,0,0,0.2);
line-height: 1.1; line-height: 1.1;
} }
.ad-recommendation__price {
font-size: 2.2rem;
font-weight: 900;
color: #ffeb3b;
margin-bottom: 1rem;
text-shadow: 0 2px 8px rgba(0,0,0,0.3);
display: inline-block;
background: rgba(0, 0, 0, 0.2);
padding: 0.2rem 1rem;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.ad-recommendation__content p { .ad-recommendation__content p {
font-size: 1.2rem; font-size: 1.2rem;
color: rgba(255, 255, 255, 0.95); color: rgba(255, 255, 255, 0.95);
@ -157,6 +173,7 @@ if ($stmt && $stmt->num_rows > 0) {
<div class="ad-recommendation__content"> <div class="ad-recommendation__content">
<span class="ad-recommendation__badge">Empfehlung des Tages</span> <span class="ad-recommendation__badge">Empfehlung des Tages</span>
<h2><?= $rModel ?></h2> <h2><?= $rModel ?></h2>
<div class="ad-recommendation__price">ab <?= $rPriceFormatted ?> &euro;</div>
<?php <?php
$descLen = function_exists('mb_strlen') ? mb_strlen($rDesc) : strlen($rDesc); $descLen = function_exists('mb_strlen') ? mb_strlen($rDesc) : strlen($rDesc);
$descShort = $descLen > 120 ? (function_exists('mb_substr') ? mb_substr($rDesc, 0, 120) : substr($rDesc, 0, 120)) . '...' : $rDesc; $descShort = $descLen > 120 ? (function_exists('mb_substr') ? mb_substr($rDesc, 0, 120) : substr($rDesc, 0, 120)) . '...' : $rDesc;