36874-vm/item_details.php
Flatlogic Bot 1d182fef38 1.1
2025-12-11 19:19:52 +00:00

47 lines
1.8 KiB
PHP

<?php include 'header.php'; ?>
<?php
require_once 'db/config.php';
$item = null;
if (isset($_GET['id'])) {
try {
$pdo = db();
$stmt = $pdo->prepare("SELECT * FROM items WHERE item_id = ?");
$stmt->execute([$_GET['id']]);
$item = $stmt->fetch();
} catch (PDOException $e) {
error_log("Database error fetching item: " . $e->getMessage());
// For production, you might redirect to an error page or show a generic error
header("Location: listings.php");
exit();
}
}
if (!$item) {
header("Location: listings.php");
exit();
}
?>
<div class="container section">
<div class="row">
<div class="col-md-8 offset-md-2">
<div class="card mb-4 shadow-sm">
<img src="https://images.pexels.com/photos/276583/pexels-photo-276583.jpeg?auto=compress&cs=tinysrgb&w=800" class="card-img-top" alt="<?php echo htmlspecialchars($item['name']); ?>" style="height: 400px; object-fit: cover;">
<div class="card-body">
<h1 class="card-title display-4 mb-3"><?php echo htmlspecialchars($item['name']); ?></h1>
<h5 class="card-subtitle mb-2 text-muted"><i data-feather="map-pin"></i> <?php echo htmlspecialchars($item['location']); ?></h5>
<p class="card-text lead"><?php echo htmlspecialchars($item['description']); ?></p>
<hr>
<div class="d-flex justify-content-between align-items-center mt-3">
<h3 class="price-text">$<?php echo htmlspecialchars(number_format($item['price_per_day'], 2)); ?> / day</h3>
<button class="btn btn-primary btn-lg">Rent Now</button>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>