<?php include("../db.php");?>
<?php include("./x.php");?>


<?php
    $user2_sql = "SELECT * FROM user2 WHERE u_id = '$x' ";
    $user2_run = mysqli_query($con, $user2_sql);
    $user2_rows = mysqli_fetch_assoc($user2_run);
?>
<?php
    $user_sql = "SELECT * FROM users WHERE uid = '$x' ";
    $user_run = mysqli_query($con, $user_sql);
    $user_rows = mysqli_fetch_assoc($user_run);
?>
<?php 
    if(isset($_GET["title"])){
        $notice = $_GET["title"];

        $notice_sql = "SELECT * FROM data_table WHERE up_by = $x AND page_type = 'notice' AND recycle = '1' AND title = '$notice'";
        $notice_run = mysqli_query($con, $notice_sql);
        $c = 1;

        if ($notice_row = mysqli_fetch_assoc($notice_run)) {
            $notice_id = $notice_row['id']; // assuming 'id' is your primary key column
            $update_sql = "UPDATE data_table SET view_count = view_count + 1 WHERE id = $notice_id";
            mysqli_query($con, $update_sql);
        }
    }
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <!-- meta tags -->
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="<?php echo $user_rows['uname'];?> | Notice | <?= $notice; ?> ">
    <meta name="keywords" content="">

    <!-- title -->
    <title><?php echo $user_rows['uname'];?> | Notice | <?= $notice; ?> </title>

    <!-- favicon -->
    <link rel="icon" type="image/x-icon" href="assets/img/logo/macaw.png">

    <?php include("include/css.php");?>

</head>

<body>


    <!-- header area -->
    <?php include("include/header.php");?>
    <!-- header area end -->


    <main class="main">

        <!-- breadcrumb -->
        <div class="site-breadcrumb" style="background: url(./login/upload/<?php echo $notice_row['image_one']?>)">
            <div class="container">
                <h2 class="breadcrumb-title">Notice Details</h2>
                <ul class="breadcrumb-menu">
                    <li><a href="index.php">Home</a></li>
                    <li class="active"><?php echo $notice_row["title"];?></li>
                </ul>
            </div>
        </div>
        <!-- breadcrumb end -->


        <!-- notice single -->
        <div class="facility-single-area py-120">
            <div class="container">
                <div class="facility-single-wrapper">
                    <div class="row">
                        <div class="col-xl-8 col-lg-8">
                            <div class="facility-details">
                                <div class="facility-details-img mb-30">
                                    <img src="./login/upload/<?php echo $notice_row['image_one'];?>" alt="thumb">
                                </div>
                                <div class="facility-details">
                                    <h3 class="mb-20"><?php echo $notice_row['title'];?></h3>
                                    <p class="mb-20">
                                        <?php echo $notice_row['short_des'];?>
                                    </p>
                                    <div class="ck-editor">
                                        <?php echo $notice_row['long_des'];?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-xl-4 col-lg-4">
                            <div class="facility-sidebar">
                                <div class="widget category">
                                    <h4 class="widget-title">All Notice</h4>
                                    <div class="category-list">
                                        <?php
                                            $faca_sql = "SELECT * FROM data_table WHERE up_by = $x && page_type = 'notice' && recycle = '1' order by id DESC";
                                            $faca_run = mysqli_query($con, $faca_sql);
                                            $c = '1';
                                            while ($faca_row = mysqli_fetch_assoc($faca_run)) {
                                                $isHovered = "";    
                                                if($notice_row['title'] == $faca_row["title"] ){
                                                    $isHovered = "active";
                                                }
                                        ?>
                                        <a href="notice-details.php?title=<?= $faca_row["title"];?>"
                                            class="<?= $isHovered; ?>"><i
                                                class="far fa-long-arrow-right"></i><?= $faca_row["title"];?></a>
                                        <?php }?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Notice single end-->

    </main>



    <!-- footer area -->
    <?php include("include/footer.php");?>
    <!-- footer area end -->

    <!-- js -->
    <?php include("include/js.php");?>

</body>

</html>