56 lines
2.0 KiB
PHP
56 lines
2.0 KiB
PHP
<?php
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
|
|
$car = null;
|
|
|
|
if ($id > 0) {
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("SELECT * FROM cars WHERE id = ?");
|
|
$stmt->execute([$id]);
|
|
$car = $stmt->fetch();
|
|
} catch (PDOException $e) {
|
|
$car = null;
|
|
}
|
|
}
|
|
|
|
if (!$car) {
|
|
header("Location: cars.php");
|
|
exit;
|
|
}
|
|
|
|
include __DIR__ . '/includes/header.php';
|
|
?>
|
|
|
|
<main>
|
|
<section class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<div class="glass-card">
|
|
<img src="<?php echo htmlspecialchars($car['main_image']); ?>" alt="<?php echo htmlspecialchars($car['brand'] . ' ' . $car['model']); ?>" class="w-100" style="border-radius: var(--radius-lg);" onerror="this.src='https://images.pexels.com/photos/170811/pexels-photo-170811.jpeg?auto=compress&cs=tinysrgb&w=600'">
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<div class="glass-card">
|
|
<h1 class="text-gold"><?php echo htmlspecialchars($car['brand'] . ' ' . $car['model']); ?></h1>
|
|
<p class="text-muted mb-4">Location: <?php echo htmlspecialchars($car['city']); ?> | Year: <?php echo $car['year']; ?></p>
|
|
|
|
<div class="car-price mb-4" style="font-size: 2.5rem;">$<?php echo number_format($car['price']); ?></div>
|
|
|
|
<div class="mb-4">
|
|
<h3 class="text-gold mb-2">Description</h3>
|
|
<p><?php echo nl2br(htmlspecialchars($car['description'])); ?></p>
|
|
</div>
|
|
|
|
<div class="d-flex gap-4">
|
|
<a href="contact.php?car_id=<?php echo $car['id']; ?>" class="btn btn-primary w-100">Contact Seller</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
|
|
<?php include __DIR__ . '/includes/footer.php'; ?>
|