<?php

include("admin/connection.php");
include('include/header.php');
?>
<?php
$slug = $_GET['slug'];
$ser = mysqli_query($con, "SELECT * FROM `supply` where slug='$slug'");
while ($row = mysqli_fetch_array($ser)) {
    $title = $row['title'];
    $short_des = $row['short_des'];
    $slug = $row['slug'];
    $Image = $row['Image'];
    $id = $row['id'];
    $description = $row['description'];
}
?>

<main class="main">

    <!-- breadcrumb -->
    <div class="site-breadcrumb" style="background: url(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">
                    <!-- Sidebar Start -->
                    <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 `supply`");
                                    while ($s = mysqli_fetch_array($services)) {
                                    ?>
                                        <a href="<?php path(); ?>/supply-details.php?slug=<?php echo $s['slug']; ?>">
                                            <i class="far fa-angle-double-right"></i> <?php echo htmlspecialchars($s['title']); ?>
                                        </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)
                        $ser = mysqli_query($con, "SELECT * FROM `supply` WHERE id = '$id'");
                        if ($row = mysqli_fetch_array($ser)) {
                            $image = $row['Image'];
                            $title = $row['title'];
                            $short_des = $row['short_des'];
                            $description = $row['description'];
                        ?>
                            <div class="service-details">
                                <div class="mb-30">
                                    <img src="<?php path(); ?>/admin/assets/images/supply/<?php echo htmlspecialchars($image); ?>" alt="Service Image">
                                </div>
                                <div class="content">
                                    <h3 class="mb-20"><?php echo htmlspecialchars($title); ?></h3>
                                    <p class="mb-20"><?php echo $description; ?></p>
                                </div>
                                <div class="mt-4">
                                    <p><?php echo $short_des; ?></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');
?>
