ok
Direktori : /home/importfo/www/importfolio.in/ |
Current File : /home/importfo/www/importfolio.in/videos.php |
<?php session_start(); $timeout_duration = 600; // Check if the user is logged in if (!isset($_SESSION['user_id'])) { header('Location: index.php'); exit; } if (isset($_SESSION['loggedin_time']) && (time() - $_SESSION['loggedin_time']) > $timeout_duration) { session_unset(); session_destroy(); header('Location: index.php?timeout=true'); exit; } else { $_SESSION['loggedin_time'] = time(); } include("admin/config.php"); // Set the number of videos per page $videos_per_page = 4; // Get the current page number from the URL, default to 1 if not present $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; // Calculate the offset for the SQL query $offset = ($page - 1) * $videos_per_page; // Fetch total number of videos $total_videos_query = "SELECT COUNT(*) FROM video"; $total_videos_result = mysqli_query($db, $total_videos_query); $total_videos = mysqli_fetch_array($total_videos_result)[0]; // Calculate the total number of pages $total_pages = ceil($total_videos / $videos_per_page); // Fetch videos for the current page $sql = "SELECT * FROM video LIMIT $offset, $videos_per_page"; $res = mysqli_query($db, $sql); ?> <!DOCTYPE html> <html lang="en"> <head> <?php include('top.php'); ?> <style> .pagination-wrapper { text-align: center; margin-top: 20px; } .pagination { display: inline-block; list-style-type: none; padding: 0; } .pagination li { display: inline; } .pagination li a { color: #000; float: left; padding: 8px 16px; text-decoration: none; border: 1px solid #ddd; margin: 0 5px; transition: background-color 0.3s; } .pagination li a:hover { background-color: #ddd; } .pagination .active a { background-color: #4CAF50; color: white; border: 1px solid #4CAF50; } </style> </head> <body> <!-- Header Start --> <?php include('header.php'); ?> <!-- Header End --> <!--Banner Start--> <section class="main-inner-banner-one"> <div class="container"> <div class="row"> <div class="col-lg-12"> <div class="breadcrum-title-one"> <h1 class="h1-title">Videos</h1> <div class="breadcrum-one"> <ul> <li><a href="index.php">Home</a></li> <li><i class="fa fa-chevron-right"></i></li> <li><a href="#">Videos</a></li> </ul> </div> </div> </div> </div> </div> </section> <!--Banner End--> <!--Videos Section Start--> <section class="main-portfolio-detail-one"> <div class="container"> <div class="portfolio-detail-img-box-one"> <div class="row"> <?php while ($row = mysqli_fetch_array($res)) { ?> <div class="col-lg-6 col-md-6"> <div class="portfolio-detail-img-one wow fadeInUp" data-wow-delay=".4s"> <iframe width="100%" height="350px" src="<?php echo $row['videolink']; ?>" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen> </iframe> </div> </div> <?php } ?> </div> </div> <!-- Pagination Start --> <div class="row"> <div class="col-lg-12"> <div class="pagination-wrapper"> <ul class="pagination"> <?php if ($page > 1): ?> <li><a href="?page=<?php echo $page - 1; ?>">« Previous</a></li> <?php endif; ?> <?php for ($i = 1; $i <= $total_pages; $i++): ?> <li <?php if ($page == $i) echo 'class="active"'; ?>> <a href="?page=<?php echo $i; ?>"><?php echo $i; ?></a> </li> <?php endfor; ?> <?php if ($page < $total_pages): ?> <li><a href="?page=<?php echo $page + 1; ?>">Next »</a></li> <?php endif; ?> </ul> </div> </div> </div> <!-- Pagination End --> </div> </section> <!--Videos Section End--> <!-- Footer Start --> <?php include('footer.php'); ?> <!-- Footer End --> </body> </html>