<?php

include("admin/connection.php");
include('include/header.php');
?>
<?php
$slug = $_GET['slug'];
$loc = mysqli_query($con, "SELECT * FROM `locations` where slug='$slug'");
while ($row = mysqli_fetch_array($loc)) {
    $location_name = $row['location_name'];
    $slug = $row['slug'];
    $Image = $row['Image'];
    $id = $row['id'];
    $location_description = $row['location_description'];
}
?>
<div class="breadcumb-wrapper" data-bg-src="<?php echo path() ?>assets/img/property-details/breadcrumb-bg.jpg">
    <div class="container">
        <div class="breadcumb-content">
            <h1 class="breadcumb-title"><?php echo $location_name; ?></h1>
            <ul class="breadcumb-menu">
                <li><a href="<?php echo path() ?>index.php">Home</a></li>
                <li>Location Details</li>
            </ul>
        </div>
    </div>
</div>
<section class="space space-extra-bottom">
    <div class="container">
        <div class="row">
            <div class="col-xxl-8 col-lg-9">
                <div class="page-single mb-2">
                    <?php
                    // Fetch service details by ID (make sure $id is defined earlier)
                    $loc = mysqli_query($con, "SELECT * FROM `locations` WHERE  id = '$id'");
                    if ($row = mysqli_fetch_array($loc)) {
                        $Image = $row['Image'];
                        $location_name = $row['location_name'];

                        $location_description = $row['location_description'];
                    ?>
                        <div class="page-img"><img src="<?php echo path(); ?>admin/assets/images/location/<?php echo htmlspecialchars($Image); ?>" alt="Service Image">

                        </div>
                        <div class="page-content">
                            <h2 class="sec-title"><?php echo $location_name; ?></h2>
                            <p class=""><?php echo $location_description; ?></p>




                        </div>
                    <?php
                    }
                    ?>
                </div>
            </div>
            <div class="col-xxl-4 col-lg-3">
                <aside class="sidebar-area">

                    <div class="widget">
                        <h3 class="widget_title">All Location</h3>
                        <?php
                        // Fetch all locations for sidebar featured listing
                        $locations = mysqli_query($con, "SELECT slug, location_name, Image FROM `locations` ORDER BY id DESC");

                        while ($l = mysqli_fetch_assoc($locations)) {
                            $slug = htmlspecialchars($l['slug']);
                            $location_name = htmlspecialchars($l['location_name']);
                            $Image = htmlspecialchars($l['Image']);
                        ?>

                            <div class="recent-post-wrap featured-listing">
                                <div class="recent-post">
                                    <div class="media-img">
                                        <a href="<?php echo path(); ?>locations/<?php echo urlencode($slug); ?>">
                                            <img src="<?php echo path(); ?>admin/assets/images/location/<?php echo htmlspecialchars($Image); ?>" alt="<?php echo $location_name; ?>">
                                        </a>
                                    </div>
                                    <div class="media-body">
                                        <h4 class="post-title">
                                            <a class="text-inherit" href="<?php echo path(); ?>locations/<?php echo urlencode($slug); ?>">
                                                <?php echo $location_name; ?>
                                            </a>
                                        </h4>
                                    </div>
                                </div>
                            </div>

                        <?php } ?>

                    </div>

                </aside>
            </div>
        </div>
    </div>
</section>
<?php

include("include/footer.php");
?>