Geizkragen/ad_recommendation.php

133 lines
3.1 KiB
PHP

<?php
require_once __DIR__ . '/lib/bootstrap.php';
$conn = db_connect();
// Fetch 1 random product
$query = "SELECT productID, model, description, imagePath FROM products ORDER BY RAND() LIMIT 1";
$result = $conn->query($query);
$adProduct = $result->fetch_assoc();
if ($adProduct):
?>
<style>
.ad-recommendation {
background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
border-radius: 12px;
padding: 20px;
margin: 20px auto;
max-width: 1200px;
display: flex;
align-items: center;
gap: 20px;
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
position: relative;
overflow: hidden;
color: #333;
}
.ad-recommendation::before {
content: 'Anzeige';
position: absolute;
top: 10px;
right: 15px;
font-size: 0.8rem;
background: rgba(255,255,255,0.7);
padding: 2px 8px;
border-radius: 4px;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
}
.ad-image-container {
flex-shrink: 0;
width: 200px;
height: 200px;
background: #fff;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
padding: 10px;
box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}
.ad-image-container img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
.ad-content {
flex-grow: 1;
}
.ad-tag {
display: inline-block;
background: #ff4757;
color: white;
padding: 5px 12px;
border-radius: 20px;
font-weight: bold;
font-size: 0.9rem;
margin-bottom: 10px;
box-shadow: 0 4px 6px rgba(255, 71, 87, 0.3);
}
.ad-title {
font-size: 1.8rem;
font-weight: 800;
margin: 0 0 10px 0;
line-height: 1.2;
}
.ad-description {
font-size: 1rem;
line-height: 1.5;
margin-bottom: 20px;
opacity: 0.9;
max-width: 600px;
}
.ad-btn {
display: inline-block;
background: #2ed573;
color: white;
text-decoration: none;
padding: 12px 24px;
border-radius: 30px;
font-weight: bold;
font-size: 1.1rem;
transition: transform 0.2s, box-shadow 0.2s;
box-shadow: 0 4px 6px rgba(46, 213, 115, 0.3);
}
.ad-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 12px rgba(46, 213, 115, 0.4);
color: white;
}
@media (max-width: 768px) {
.ad-recommendation {
flex-direction: column;
text-align: center;
padding: 30px 15px;
}
.ad-image-container {
width: 100%;
max-width: 250px;
}
.ad-title {
font-size: 1.5rem;
}
}
</style>
<div class="ad-recommendation">
<div class="ad-image-container">
<img src="<?= htmlspecialchars($adProduct['imagePath']) ?>" alt="<?= htmlspecialchars($adProduct['model']) ?>">
</div>
<div class="ad-content">
<div class="ad-tag">🔥 Empfehlung des Tages</div>
<h2 class="ad-title"><?= htmlspecialchars($adProduct['model']) ?></h2>
<p class="ad-description">
<?= htmlspecialchars(mb_strimwidth($adProduct['description'], 0, 150, "...")) ?>
</p>
<a href="productpage.php?id=<?= $adProduct['productID'] ?>" class="ad-btn">Jetzt entdecken</a>
</div>
</div>
<?php endif; ?>