Viewing file: index.php (9.83 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include('header.php') ?>
<section class="section first-section"> <div class="container-fluid"> <div class="masonry-blog clearfix"> <?php $sql = "SELECT * FROM articles WHERE art_status=1 ORDER BY art_id DESC LIMIT 3"; $res = mysqli_query($conn, $sql); // Corrected: use $sql instead of $res
if ($res && mysqli_num_rows($res) > 0) { $side_classes = ['left-side', 'center-side', 'right-side hidden-md-down']; $i = 0;
while ($row = mysqli_fetch_assoc($res)) { $title = $row['art_title']; $art_sub_title = $row['art_sub_title']; $image = $row['art_image']; // Make sure your DB has an 'image' column $date = date('d M, Y', strtotime($row['art_create_dt'])); $author = $row['art_author']; $link = "article-single.php?id=" . $row['art_id']; // Link to article detail page
echo '<div class="' . $side_classes[$i] . '"> <div class="masonry-box post-media"> <img src="./admin/' . $image . '" alt="' . $title . '" class="img-fluid" style="width:600px;height: 300px;"> <div class="shadoweffect"> <div class="shadow-desc"> <div class="blog-meta"> <span class="bg-aqua"><a href="#" title="">' . htmlspecialchars($art_sub_title) . '</a></span> <h4><a href="' . $link . '" title="">' . htmlspecialchars($title) . '</a></h4> <small><a href="' . $link . '" title="">' . $date . '</a></small> <small><a href="#" title="">by ' . htmlspecialchars($author) . '</a></small> </div> </div> </div> </div> </div>'; $i++; } } ?> </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 = 3; $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"> <span class="bg-aqua"><a href="category.php?cat=<?= urlencode($category) ?>" title=""><?= htmlspecialchars($category) ?></a></span> <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') ?>
|