Merge remote-tracking branch 'origin/main'

This commit is contained in:
Fabian Schieder 2026-02-11 16:22:16 +01:00
commit 6b92b14a77
2 changed files with 36 additions and 25 deletions

View File

View File

@ -36,12 +36,31 @@ $productId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
<?php else: ?>
<?php
$stmt = $conn->prepare("
SELECT productID, model, description, imagePath
FROM products
WHERE productID = ?
LIMIT 1
SELECT
a.name,
a.unit,
a.dataType,
pa.valueString,
pa.valueNumber,
pa.valueBool
FROM products p
INNER JOIN categoryAttributes ca
ON p.categoryID = ca.categoryID
INNER JOIN attributes a
ON ca.attributeID = a.attributeID
LEFT JOIN productAttributes pa
ON pa.productID = p.productID
AND pa.attributeID = a.attributeID
WHERE p.productID = ?
ORDER BY a.attributeID
");
$stmt->bind_param("i", $productId);
$stmt->execute();
@ -49,27 +68,19 @@ $productId = isset($_GET['id']) ? (int)$_GET['id'] : 0;
$product = $result->fetch_assoc();
?>
<?php if ($product): ?>
<section class="product-section">
<div class="product-scroll">
<div class="product-card">
<img
src="<?= isset($product['imagePath']) ? $product['imagePath'] : 'assets/images/placeholder.png' ?>"
alt="<?= htmlspecialchars($product['model']) ?>">
<?php
while ($row = $result->fetch_assoc()) {
echo "<p><strong>{$row['name']}:</strong> ";
if (!empty($row['valueString'])) echo $row['valueString'];
if (!empty($row['valueNumber'])) echo $row['valueNumber'] . " " . $row['unit'];
if (!is_null($row['valueBool'])) echo $row['valueBool'] ? "Ja" : "Nein";
echo "</p>";
}
?>
<div class="product-card__content">
<h3><?= htmlspecialchars($product['model']) ?></h3>
<p><?= htmlspecialchars($product['description']) ?></p>
</div>
</div>
</div>
</section>
<?php else: ?>
<section class="product-section">
<h2>Produkt nicht gefunden</h2>
<p>Zu dieser ID gibt es kein Produkt.</p>
</section>
<?php endif; ?>
<?php $stmt->close(); ?>
<?php endif; ?>