<?php

include("admin/connection.php");
include('include/header.php');
?>
<?php
$slug = $_GET['slug'];
$ser = mysqli_query($con, "SELECT * FROM `service` where slug='$slug'");
while ($row = mysqli_fetch_array($ser)) {
    $title = $row['title'];

    $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 $title; ?></h2>
            <ul class="breadcrumb-menu">
                <li><a href="index.php">Home</a></li>
                <li class="active"><?php echo $title; ?></li>
            </ul>
        </div>
    </div>
    <!-- breadcrumb end -->


    <!-- service single -->
    <div class="service-single py-120">
        <div class="container">
            <div class="service-single-wrap">
                <div class="row">

                    <div class="col-xl-8 col-lg-8">
                        <?php
                        // Fetch service details by ID (make sure $id is defined earlier)
                        $ser = mysqli_query($con, "SELECT * FROM `service` WHERE id = '$id'");
                        if ($row = mysqli_fetch_array($ser)) {
                            $image = $row['Image'];
                            $title = $row['title'];

                            $description = $row['description'];
                        ?>
                            <div class="service-details">
                                <div class="mb-30">
                                    <img src="<?php path(); ?>admin/assets/images/service/<?php echo htmlspecialchars($image); ?>" alt="Service Image">
                                </div>
                                <div class="content">
                                    <h3 class="mb-20"><?php echo htmlspecialchars($title); ?></h3>
                                    <p class="mb-20" style="text-align: justify;"><?php echo $description; ?></p>
                                </div>
                                
                            </div>
                        <?php
                        } else {
                            echo "<p>Service not found.</p>";
                        }
                        ?>
                    </div>
                    <div class="col-xl-4 col-lg-4">
                        <div class="service-sidebar">
                            <div class="widget">
                                <h4 class="title">All Services</h4>
                                <div class="category">
                                    <?php
                                    // Fetch all services for the sidebar list
                                    $services = mysqli_query($con, "SELECT slug, title FROM `service`");
                                    while ($s = mysqli_fetch_array($services)) {
                                        $slug = htmlspecialchars($s['slug']);
                                        $title = htmlspecialchars($s['title']);
                                    ?>
                                        <a href="<?php echo path(); ?>products/<?php echo $slug; ?>">
                                            <i class="far fa-angle-double-right"></i> <?php echo htmlspecialchars($s['title']); ?>
                                        </a>
                                    <?php
                                    }
                                    ?>
                                </div>
                            </div>
                            <div class="widget">
                                <h4 class="title">Download</h4>
                                <div class="service-download">
                                    <a href="assets/img/BROCHURE.pdf" download><i class="far fa-file-pdf"></i> Download Brochure</a>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- service single end -->

</main>


<?php
include("include/footer.php");
?>