<?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'];
    $description = $row['description'];
}
?>

<main class="main">

    <!-- breadcrumb -->
    <div class="site-breadcrumb" style="background: url(<?php path() ?>assets/img/breadcrumb/01.jpg)">
        <div class="container">
            <h2 class="breadcrumb-title"><?php echo $location_name; ?></h2>
            <ul class="breadcrumb-menu">
                <li><a href="index.php">Home</a></li>
                <li class="active"><?php echo $location_name; ?></li>
            </ul>
        </div>
    </div>
    <!-- breadcrumb end -->


    <!-- service single -->
    <div class="service-single mt-5 mb-5">
        <div class="container">
            <div class="service-single-wrap">
                <div class="row flex-row-reverse">
                    <!-- Sidebar Start -->
                     <div class="col-xl-4 col-lg-4">
                        <div class="service-sidebar">
                            <div class="widget">
                                <h4 class="title">All location</h4>
                                <div class="category">
                                    <?php
                                    // Fetch all services for the sidebar list
                                    $locations = mysqli_query($con, "SELECT slug, location_name FROM `locations` ORDER BY id DESC");
                                    while ($l = mysqli_fetch_array($locations)) {
                                    ?>
                                        <a href="<?php echo path(); ?>locations/<?php echo htmlspecialchars($l['slug']); ?>">
                                            <i class="far fa-angle-double-right"></i> <?php echo htmlspecialchars($l['location_name']); ?>
                                        </a>
                                    <?php
                                    }
                                    ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Sidebar End -->

                    <!-- Main Service Content Start -->
                    <div class="col-xl-8 col-lg-8">
                        <?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'];
                          
                            $description = $row['description'];
                        ?>
                            <div class="service-details">
                                <div class="mb-30">
                                    <img src="<?php path(); ?>admin/assets/images/location/<?php echo htmlspecialchars($Image); ?>" alt="Service Image">
                                </div>
                                <div class="content">
                                    <h3 class="mb-20"><?php echo htmlspecialchars($location_name); ?></h3>
                                    <p class="mb-20"><?php echo $description; ?></p>
                                </div>
                              
                            </div>
                        <?php
                        } else {
                            echo "<p>Service not found.</p>";
                        }
                        ?>
                    </div>
                   
                    <!-- Main Service Content End -->
                </div>

            </div>
        </div>
    </div>
    </div>
    <!-- service single end -->

</main>


<?php
include('include/footer.php');
?>