<?php
include("include/config.php");
$id=$_GET['option'];

// RewriteEngine on

// RewriteRule ^news/([a-zA-Z0-9-/]+)$ first.php?option=$1  

 //$url=base64_decode($id);
 
          $new_q="SELECT * FROM `news` where `url`='$id'";
            $new_q_execute=mysqli_query($conn,$new_q);
           
           $new_count=mysqli_num_rows($new_q_execute);
            if($new_count){
                
                $data=mysqli_fetch_assoc($new_q_execute);
                 $title=$data['title'];
                  $uploaded_on=$data['upload_on'];
                    $new_img=$data['images'];
                    
            }
            
            
            include("include/header.php");
?>
<style>
    .single-blog-details .featured-thubnail {
        margin-bottom: 20px;
        height: 400px !important;
        width: 100%;
        border-radius: 5px;
        box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
    }

    .single-blog-details h1 {
        font-size: 26px;
        text-transform: capitalize;
        line-height: 2.5rem;

    }

    .single-blog-details .post-meta {
        /*font-size: 22px;*/
        text-transform: capitalize;
    }

    .single-blog-details .myph {
        height: auto !important;
    }

    #owl-demo .item img {
        display: block;
        width: 100%;
        height: auto;
    }

    @media only screen and (max-width: 767px) {
        .single-blog-details .featured-thubnail {
            height: auto !important;
            width: 100% !important;
        }
    }

</style>
<section class="page-banner-wrap d-flex align-items-center">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="page-banner">
                    <h2>News</h2>
                    <ul>
                        <li><a href="<?php echo $base_url;?>">home</a></li>
                        <li><a href="javascript:void(0);"> News</a></li>
                        <li><a href="javascript:void(0);"><?php echo $title;?></a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</section> <!-- /.page-banner-wrap -->

<section class="blog-details section-padding">
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-12">
                <div class="single-blog-details">

                    <?php
				     $admin_base_url_new="https://afsarebrahim.com/admin/news/newsgallery/";
				   
				    $newImgArray=explode(",",$new_img);
				   $count=count($newImgArray);
				    ?>
                  

                    <?php
					if($count==1){
					   
					     $singleImg=$newImgArray[0];
					    ?>
                    <img class="featured-thubnail" alt="<?php echo $title;?>" src="<?php echo $admin_base_url_new.$singleImg;?>" style="height:auto !important;">

                    <?php
					}else{
					    
					    
					    ?>
                    <div id="owl-demo" class="owl-carousel owl-theme">
                        <?php
                                foreach($newImgArray as $value){
                                    
                                    ?>
                        <div class="item"><img src="<?php echo $admin_base_url_new.$value;?>" alt="The Last of us"></div>
                        <?php
                                    
                                }
                                
                                ?>



                    </div>

                    <?php
					}
					
					?>
                    <h1><?php echo $title;?></h1>
                    <div class="post-meta mt-3">
                        <span class="p-date"><strong>Date:</strong><?php echo $uploaded_on;?></span>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="p-author"><strong>Posted by:</strong><?php echo "
Afsar Ebrahim";?></span>
                    </div>

                </div> <!-- /.single-blog-details -->


            </div> <!-- /.col-lg-8 col-sm-12 -->


            <!-- blog sidebar section -->
            <div class="col-lg-4 col-12 sidebar-wrapper">


                <div class="single-sidebar-widgets recent-post">
                    <h3>Recent News</h3>
                    <?php
					
            $sql1m1 = "select * from `news` ORDER BY `news`.`id` DESC LIMIT 10;";	

         $result1m1 = mysqli_query($conn, $sql1m1);											
         if (mysqli_num_rows($result1m1) > 0) {
        $i=1;
        while($row1m1 = mysqli_fetch_assoc($result1m1)) {
            $det_titles = $row1m1['title'];
           
            $newid=$row1m1['id'];
	    	$det_date_add1 = $row1m1['upload_on'];
	    	 $news_url=base64_encode($newid);
	    	 
	    	 $newUrl=$row1m1['url'];
            		?>
                    <div class="single-populer-post">
                        <span><?php echo $det_date_add1;?></span>
                        <a href="<?php echo $base_url . 'news/' .$newUrl; ?>"><?php echo $det_titles;?></a>

                    </div> <!-- /.single-populer-post -->
                    <?php }}?>
                </div> <!-- /.single-sidebar-widgets -->

                <div class="single-sidebar-widgets">
                    <h3>Follow us</h3>
                    <div class="social-links">
                        <a href="<?php echo $fb_link;?>" target="_blank"><i class="fab fa-facebook-f"></i></a>
                        <!--<a href="<?php echo $fb_twitter;?>" target="_blank"><i class="fab fa-twitter"></i></a>-->
                        <a href="<?php echo $fb_linkedIn;?>" target="_blank"><i class="fab fa-linkedin-in"></i></a>
                        <!--<a href="<?php echo $fb_Insta;?>" target="_blank"><i class="fab fa-instagram"></i></a>-->
                    </div>
                </div> <!-- /.single-sidebar-widgets -->

            </div> <!-- /.col-lg-4 col-sm-12 -->
        </div>
    </div>
</section>


<?php include "include/footer.php"; ?>
<script>
    $(document).ready(function() {

        $("#owl-demo").owlCarousel({
              loop:true,
            navigation: true, // Show next and prev buttons
            autoplayTimeout: 5000,
            autoplay:true,
            slideSpeed: 300,
            paginationSpeed: 400,

            items: 1,
            itemsDesktop: false,
            itemsDesktopSmall: false,
            itemsTablet: false,
            itemsMobile: false

        });

    });

</script>
