<?php
$Current_Page = 'resource-center.php';
//require("P_Initialization.php");//
?>
<?php 
require 'include/dbconn.php';
$pdo = dbConnforTutle::getConnection();
  
$stmt = $pdo->prepare('SELECT * FROM blog WHERE publish_date <= NOW() ORDER BY `publish_date` DESC LIMIT 6');
$stmt->execute();
$newData = $stmt->fetchAll();

$allStmt = $pdo->prepare('SELECT * FROM blog WHERE publish_date <= NOW() ORDER BY `publish_date` DESC');
$allStmt->execute();
$allData = $allStmt->fetchAll();

function limitText($text, $limit = 50) {
    if (strlen($text) <= $limit) {
        return $text;
    }
    return substr($text, 0, $limit) . '...';
}
 
?>
<!DOCTYPE html>
<html lang="zxx">


<head>
	<!-- Meta -->
	<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="">
	<meta name="keywords" content="">
	<meta name="author" content="">
	<!-- Page Title -->
	<title>Tathagat</title>
	<!-- Favicon Icon -->
	<link rel="shortcut icon" type="image/x-icon" href="images/favicon.png">
    <!-- Google Fonts css-->
    <link rel="preconnect" href="https://fonts.googleapis.com/">
    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1,300..900&amp;display=swap" rel="stylesheet">
	<!-- Bootstrap Css -->
	<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
	<!-- SlickNav Css -->
	<link href="css/slicknav.min.css" rel="stylesheet">
	<!-- Swiper Css -->
	<link rel="stylesheet" href="css/swiper-bundle.min.css">
	<!-- Font Awesome Icon Css-->
	<link href="css/all.css" rel="stylesheet" media="screen">
	<!-- Animated Css -->
	<link href="css/animate.css" rel="stylesheet">
	<!-- Magnific Popup core CSS file -->
	<link rel="stylesheet" href="css/magnific-popup.css">
	<!-- Main custom Css -->
	<link href="css/custom.css" rel="stylesheet" media="screen">
	<style>
	.card p{padding:10px;}
	</style>
</head>

<body class="tt-magic-cursor">
	<?php include'header.php'?>
	
	

	<!-- Resource Section Start -->
	<div class="about-us pt-0" >
		<div class="container">
			<div class="row align-items-center">
				<!-- Section Title Start -->
                <div class="section-title text-center">
                    <h2 class="text-anime-style-3"><span>Resource  </span>Center</h2>
                </div>

                <!-- Section Title End -->
			</div>
            <div class="casestory-slider">
				<h4>Recents</h4>
					<hr/>
					<div class="swiper">
						<div class="swiper-wrapper">
							<!-- casestory Slide Start -->
							<?php for($i=0;$i<count($newData);$i++){ ?> 
							<div class="swiper-slide">
								<div class="card bg-dark text-white border-0 rounded-4 overflow-hidden">
										<a href="article-details.php?blog=<?=$newData[$i]['slug']?>"><img src="admin/images/blog/<?=$newData[$i]['imagename']?>" class="card-img" alt="...">
									<h5><?= limitText($newData[$i]['title'], 90)?></h5> 
									<?php
								if (!empty($newData[$i]['publish_date'])) {
									try {
										$dt = new DateTime($newData[$i]['publish_date']);
										echo '<p style="font-style:italic;text-align:right;color:#fff;">' . htmlspecialchars($dt->format('jS F, Y')) . '</p>';
									} catch (Exception $e) {
										echo '<p style="font-style:italic;text-align:right;color:#fff;">' . htmlspecialchars($newData[$i]['publish_date']) . '</p>';
									}
								}
								?>
									</a>
								</div>
								</div>
							<?php } ?>
						 
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

<!-- Resource Section Start -->
	<div class="about-us pt-0" >
		<div class="container">
			
            <div class="row">
				<h4>All Articles</h4><br/><br/>
					<hr/>
							<!-- casestory Slide Start -->
							 <?php for($j=0;$j<count($allData);$j++){ ?>

								
							<div class="col-lg-4">
								<div class="card bg-dark text-white border-0 overflow-hidden">
									<a href="article-details.php?blog=<?=$allData[$j]['slug']?>"><img  src="admin/images/blog/<?=$allData[$j]['imagename']?>"  class="card-img" alt="...">
									<h5><?=limitText($allData[$j]['title'], 90)?></h5> 
							     
							    		<?php
								if (!empty($allData[$j]['publish_date'])) {
									try {
										$dt = new DateTime($allData[$j]['publish_date']);
										echo '<p style="font-style:italic;text-align:right;color:#fff;">' . htmlspecialchars($dt->format('jS F, Y')) . '</p>';
									} catch (Exception $e) {
										echo '<p style="font-style:italic;text-align:right;color:#fff;">' . htmlspecialchars($newData[$i]['publish_date']) . '</p>';
									}
								}
								?>
								</a>
								</div>
							</div>
							<?php } ?>

							<!-- <div class="col-lg-4">
								<div class="card bg-dark text-white border-0  overflow-hidden">
									<a href="article-details.php"><img src="images/article2.png" class="card-img" alt="...">
									<h5>Top 3 Exercises for a Healthy Heart: Cardio, Strength & Flexibility Explained</h5></a>
								</div>
							</div>
							<div class="col-lg-4">
								<div class="card bg-dark text-white border-0  overflow-hidden">
									<a href="article-details.php"><img src="images/article3.png" class="card-img" alt="...">
									<h5>Tathagat Heart Hospital: A Journey of Compassionate Cardiac Care</h5></a>
								</div>
							</div>
							<div class="col-lg-4">
								<div class="card bg-dark text-white border-0  overflow-hidden">
									<a href="article-details.php"><img src="images/article1.png" class="card-img" alt="...">
									<h5>Stress and Heart Health: How to Protect Your Heart from the Inside Out</h5></a>
								</div>
							</div>
							<div class="col-lg-4">
								<div class="card bg-dark text-white border-0 overflow-hidden">
									<a href="article-details.php"><img src="images/article2.png" class="card-img" alt="...">
									<h5>Stress and Heart Health: How to Protect Your Heart from the Inside Out</h5></a>
								</div>
							</div>
							<div class="col-lg-4">
								<div class="card bg-dark text-white border-0 overflow-hidden">
									<a href="article-details.php"><img src="images/article3.png" class="card-img" alt="...">
									<h5>Stress and Heart Health: How to Protect Your Heart from the Inside Out</h5></a>
								</div>
							</div> -->

			</div>
		</div>
	</div>
	
	<!-- Instagram Section -->
	<section class="instagram-section text-center">
	<div class="container">
		<div class="row">
			<div class="col-lg-9 col-md-9">
				<div class="medical-service-heading">
					<!-- Section Title Start -->
					<div class="section-title">
						<h3 class="wow fadeInUp">FOLLOW US</h3>
						<h2 class="text-anime-style-3"><span>Follow Us On </span>  Instagram</h2>
						
					</div>
					<!-- Section Title End -->
				</div>
			</div>
			<div class="col-lg-3 col-md-3">
				<a href="#" class="btn-default wow fadeInUp" data-wow-delay="0.5s">Follow Us</a>
			</div>
		</div>

		<!-- Instagram Images -->
		<div class="row row-cols-2 row-cols-sm-4 row-cols-md-5 g-3 insta-images">
		<div class="col"><img src="images/insta1.jpg" alt="img1"></div>
		<div class="col"><img src="images/insta2.jpg" alt="img2"></div>
		
		<div class="col"><img src="images/insta4.jpg" alt="img4"></div>
		<div class="col"><img src="images/insta3.jpg" alt="img3"></div>
		<div class="col"><img src="images/insta5.jpg" alt="img5"></div>
		<div class="col"><img src="images/insta6.jpg" alt="img6"></div>
		
		<div class="col"><img src="images/insta8.jpg" alt="img8"></div>
		<div class="col"><img src="images/insta4.jpg" alt="img7"></div>
		<div class="col"><img src="images/insta9.jpg" alt="img7"></div>
		<div class="col"><img src="images/insta2.jpg" alt="img7"></div>
		</div>
	</div>
	</section>
	
	<?php include'footer.php'?>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js'></script>
	 <script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/js/bootstrap.min.js'></script>

    <!-- Validator js file -->
    <script src="js/validator.min.js"></script>
    <!-- SlickNav js file -->
    <script src="js/jquery.slicknav.js"></script>
    <!-- Swiper js file -->
    <script src="js/swiper-bundle.min.js"></script>
    <!-- Counter js file -->
    <script src="js/jquery.waypoints.min.js"></script>
    <script src="js/jquery.counterup.min.js"></script>
    <!-- Magnific js file -->
    <script src="js/jquery.magnific-popup.min.js"></script>
    <!-- SmoothScroll -->
    <script src="js/SmoothScroll.js"></script>
    <!-- Parallax js -->
    <script src="js/parallaxie.js"></script>
    <!-- MagicCursor js file -->
    <script src="js/gsap.min.js"></script>
    <script src="js/magiccursor.js"></script>
    <!-- Text Effect js file -->
    <script src="js/SplitText.js"></script>
    <script src="js/ScrollTrigger.min.js"></script>
    <!-- Wow js file -->
    <script src="js/wow.js"></script>
    <!-- Main Custom js file -->
    <script src="js/function.js"></script>
	
</body>


</html>