Viewing file: index.php (9.62 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include('header.php') ?>
<style> .swiper { width: 100%; padding: 20px 0; }
.card { border-radius: 10px; overflow: hidden; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); background: #fff; } </style>
<section class="section first-section"> <div class="container-fluid"> <div class="masonry-blog clearfix"> <div class="swiper mySwiper"> <div class="swiper-wrapper"> <?php $sql = "SELECT * FROM banners ORDER BY ban_id DESC"; $res = mysqli_query($conn, $sql); if ($res && mysqli_num_rows($res) > 0) { while ($row = mysqli_fetch_assoc($res)) { $image = $row['ban_image']; echo ' <div class="swiper-slide"> <div class="card"> <img src="./admin/' . $image . '" alt="Banner" class="img-fluid" style="width:100%; height:300px; object-fit:cover; border-radius:10px;"> </div> </div>'; } } ?> </div> </div>
</div><!-- end masonry -->
</div> </section>
<section class="section wb"> <div class="container"> <div class="row"> <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12"> <div class="page-wrapper"> <div class="blog-list clearfix"> <?php // Sample DB connection (replace with your actual connection)
// Pagination setup $limit = 10; $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; $start = ($page - 1) * $limit;
// Fetch articles $sql = "SELECT * FROM articles WHERE art_status=1 ORDER BY art_id DESC LIMIT $start, $limit"; $res = mysqli_query($conn, $sql); ?>
<?php while ($row = mysqli_fetch_assoc($res)) { $image = $row['art_image']; $title = $row['art_title']; $category = $row['art_sub_title']; // $description = substr($row['description'], 0, 180); // shorten for preview $date = date('d M, Y', strtotime($row['art_create_dt'])); $author = $row['art_author']; // $views = $row['views']; // if you track views $link = "article-single.php?id=" . $row['art_id']; ?>
<div class="blog-box row"> <div class="col-md-4"> <div class="post-media"> <a href="<?= $link ?>" title=""> <img src="./admin/<?= $image ?>" alt="<?= $title ?>" class="img-fluid"> <div class="hovereffect"></div> </a> </div> </div>
<div class="blog-meta big-meta col-md-8"> <?php if($category!==''){ ?> <span class="bg-aqua"><a href="category.php?cat=<?= urlencode($category) ?>" title=""><?= htmlspecialchars($category) ?></a></span> <?php }else{ ?> <?php } ?> <h4><a href="<?= $link ?>" title=""><?= htmlspecialchars($title) ?></a></h4> <!-- <p><?= htmlspecialchars($description) ?>...</p> --> <!-- <small><a href="<?= $link ?>" title=""><i class="fa fa-eye"></i> <?= $views ?></a></small> --> <small><a href="<?= $link ?>" title=""><?= $date ?></a></small> <small><a href="#" title="">by <?= htmlspecialchars($author) ?></a></small> </div> </div>
<hr class="invis">
<?php } ?> <?php // Get total posts count $countRes = mysqli_query($conn, "SELECT COUNT(*) AS total FROM articles WHERE art_status=1"); $total = mysqli_fetch_assoc($countRes)['total']; $pages = ceil($total / $limit); ?>
<div class="row"> <div class="col-md-12"> <nav aria-label="Page navigation"> <ul class="pagination justify-content-start"> <?php for ($i = 1; $i <= $pages; $i++): ?> <li class="page-item <?= ($i === $page) ? 'active' : '' ?>"> <a class="page-link" href="?page=<?= $i ?>"><?= $i ?></a> </li> <?php endfor; ?> <?php if ($page < $pages): ?> <li class="page-item"> <a class="page-link" href="?page=<?= $page + 1 ?>">Next</a> </li> <?php endif; ?> </ul> </nav> </div> </div>
</div><!-- end col --> </div><!-- end blog-list --> </div><!-- end page-wrapper -->
<div class="col-lg-3 col-md-12 col-sm-12 col-xs-12"> <div class="sidebar"> <!-- <div class="widget"> <h2 class="widget-title">Search</h2> <form class="form-inline search-form"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search on the site"> </div> <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button> </form> </div>end widget -->
<div class="widget"> <h2 class="widget-title">Recent Posts</h2> <div class="blog-list-widget"> <div class="list-group"> <?php $sql = "SELECT * FROM articles WHERE art_status=1 ORDER BY art_id DESC LIMIT 5"; $res = mysqli_query($conn, $sql); // Corrected: use $sql instead of $res
if ($res && mysqli_num_rows($res) > 0) { while ($row = mysqli_fetch_assoc($res)) { $image = $row['art_image']; $title = $row['art_title']; $category = $row['art_sub_title']; // $description = substr($row['description'], 0, 180); // shorten for preview $date = date('d M, Y', strtotime($row['art_create_dt'])); $author = $row['art_author']; // $views = $row['views']; // if you track views $link = "article-single.php?id=" . $row['art_id'];
?> <a href="article-single.php" class="list-group-item list-group-item-action flex-column align-items-start"> <div class="w-100 justify-content-between"> <img src="./admin/<?= $image ?>" alt="" class="img-fluid float-left"> <h5 class="mb-1"><?= $title ?></h5> <small><?= $date ?></small> </div> </a>
<?php } } ?> </div> </div><!-- end blog-list --> </div><!-- end widget -->
</div><!-- end sidebar --> </div><!-- end col --> </div><!-- end row --> </div><!-- end container --> </section>
<?php include('footer.php') ?> <script> var swiper = new Swiper(".mySwiper", { loop: true, spaceBetween: 30, autoplay: { delay: 2000, disableOnInteraction: false, }, breakpoints: { // Mobile first 0: { slidesPerView: 1 }, 768: { slidesPerView: 2 }, 992: { slidesPerView: 3 } } }); </script>
|