<?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["blog"])){
        $blog = $_GET["blog"];

        $blog_sql = "SELECT * FROM data_table WHERE up_by = $x && page_type = 'blog' && recycle = '1' && title = '$blog'";
        $blog_run = mysqli_query($con, $blog_sql);
        $c = '1';
        if ($blog_row = mysqli_fetch_assoc($blog_run)) {
        }
    }
?>

<!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'];?> | Blog | <?= $blog; ?> ">
    <meta name="keywords" content="">

    <!-- title -->
    <title><?php echo $user_rows['uname'];?> | Blog | <?= $blog; ?> </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 $blog_row['image_thumbnail']?>)">
            <div class="container">
                <h2 class="breadcrumb-title">Blog Single</h2>
                <ul class="breadcrumb-menu">
                    <li><a href="index.html">Home</a></li>
                    <li class="active">Blog Single</li>
                </ul>
            </div>
        </div>
        <!-- breadcrumb end -->


        <!-- blog single area -->
        <div class="blog-single-area pt-120 pb-120">
            <div class="container">
                <div class="row">
                    <div class="col-lg-8">
                        <div class="blog-single-wrapper">
                            <div class="blog-single-content">
                                <div class="blog-thumb-img">
                                    <img src="./login/upload/<?php echo $blog_row['image_thumbnail']?>" alt="thumb">
                                </div>
                                <div class="blog-info">
                                    <div class="blog-meta">
                                        <div class="blog-meta-left">
                                            <ul>
                                                <li><i class="far fa-user"></i><a href="#">MACAW Public School</a></li>
                                                <li><i class="far fa-eye"></i><?= $blog_row["view_count"]; ?> Views</li>
                                                <li><i class="far fa-clock"></i><?= $blog_row["up_date"]; ?>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>
                                    <div class="blog-details">
                                        <h3 class="blog-details-title mb-20"><?= $blog_row["title"]; ?>
                                        </h3>
                                        <p class="mb-10">
                                            <?= $blog_row["short_des"]; ?>
                                        </p>

                                        <div class="row">
                                            <?= $blog_row["long_des"]; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <aside class="sidebar">
                            <!-- recent post -->
                            <div class="widget recent-post">
                                <h5 class="widget-title">Recent Post</h5>
                                <?php
                                    $faca_sql = "SELECT * FROM data_table WHERE up_by = $x && page_type = 'blog' && 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($blog_row['title'] == $faca_row["title"] ){
                                            $isHovered = "active";
                                        }
                                ?>
                                <div class="recent-post-single">
                                    <div class="recent-post-img">
                                        <img src="./login/upload/<?php echo $faca_row['image_thumbnail']?>" alt="thumb">
                                    </div>
                                    <div class="recent-post-bio">
                                        <h6><a
                                                href="blog-details.php?blog=<?= urlencode($faca_row["title"]); ?>"><?= $faca_row["title"];?></a>
                                        </h6>
                                        <span><i class="far fa-clock"></i><?= $faca_row["up_date"];?></span>
                                    </div>
                                </div>
                                <?php } ?>
                            </div>
                        </aside>
                    </div>
                </div>
            </div>
        </div>
        <!-- blog single area end -->

    </main>



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

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

</body>

</html>