Viewing file: article-single.php (12.94 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include('header.php'); $id = $_GET['id']; $sql = "SELECT * FROM articles as a JOIN article_content_table as b ON a.art_id = b.art_for_id JOIN admin_login as c ON a.art_create_by = c.Admin_ID WHERE a.art_id = $id"; $result = mysqli_query($conn, $sql); if ($result && mysqli_num_rows($result) > 0) { $article = mysqli_fetch_assoc($result); } else { } ?> <div class="page-title wb"> <div class="container"> <div class="row"> <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12"> <h2><i class="fa fa-leaf bg-green"></i> Blog</h2> </div><!-- end col --> <div class="col-lg-4 col-md-4 col-sm-12"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="index.php">Home</a></li> <li class="breadcrumb-item active">Blog</li> </ol> </div><!-- end col --> </div><!-- end row --> </div><!-- end container --> </div><!-- end page-title -->
<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-title-area"> <h3><?= $article['art_title'] ?></h3> <?php $category = $article['art_sub_title']; if($category!==''){ ?> <span class="color-green"><a href="article-single.php?id=<?=$id?>" title=""><?= $article['art_sub_title'] ?></a></span> <?php }else{ ?> <?php } ?>
<div class="blog-meta big-meta"> <small><a href="article-single.php?id=<?=$id?>" title=""><?= date('d M, Y', strtotime($article['art_create_dt'])) ?></a></small> <small><a href="article-single.php?id=<?=$id?>" title=""><?= $article['art_author'] ?></a></small> </div><!-- end meta -->
</div><!-- end title -->
<div class="single-post-media"> <img src="./admin/<?= $article['art_image'] ?>" alt="" class="img-fluid"> </div><!-- end media -->
<div class="blog-content"> <div class="pp"> <?= $article['art_intro'] ?> <?php $sql_art = "SELECT * FROM article_content_table WHERE art_for_id = $id"; $res_art = mysqli_query($conn, $sql_art);
if ($res_art) {
while ($rows = mysqli_fetch_assoc($res_art)) { ?> <div class="article_head"> <h4><?= $rows['art_heading_name'] ?></h4> </div> <div class="article_body"> <p><?= $rows['art_body_contents'] ?></p> </div>
<?php
} }
?> <?= $article['art_conclusion'] ?>
</div><!-- end pp -->
</div><!-- end content -->
<div class="blog-title-area"> <div class="tag-cloud-single"> <!-- <span>Tags</span> <small><a href="#" title="">lifestyle</a></small> <small><a href="#" title="">colorful</a></small> <small><a href="#" title="">trending</a></small> <small><a href="#" title="">another tag</a></small> --> </div><!-- end meta -->
</div><!-- end title --> <hr class="invis1">
<div class="custombox authorbox clearfix"> <h4 class="small-title">About author</h4> <div class="row"> <!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> <img src="upload/author.jpg" alt="" class="img-fluid rounded-circle"> </div>end col -->
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12"> <h4><a href="#"><?= $article['art_author'] ?></a></h4> <p><?= $article['Admin_Desc'] ?></p>
<div class="topsocial"> <a href="#" data-toggle="tooltip" data-placement="bottom" title="Facebook"><i class="fa fa-facebook"></i></a> <a href="#" data-toggle="tooltip" data-placement="bottom" title="Youtube"><i class="fa fa-youtube"></i></a> <a href="#" data-toggle="tooltip" data-placement="bottom" title="Pinterest"><i class="fa fa-pinterest"></i></a> <a href="#" data-toggle="tooltip" data-placement="bottom" title="Twitter"><i class="fa fa-twitter"></i></a> <a href="#" data-toggle="tooltip" data-placement="bottom" title="Instagram"><i class="fa fa-instagram"></i></a> <a href="#" data-toggle="tooltip" data-placement="bottom" title="Website"><i class="fa fa-link"></i></a> </div><!-- end social -->
</div><!-- end col --> </div><!-- end row --> </div><!-- end author-box -->
<hr class="invis1">
<hr class="invis1">
<?php $limit = 5; // number of comments per page $sql = "SELECT * FROM comments WHERE cmt_art_id=$id ORDER BY cmt_id DESC LIMIT $limit"; $res = mysqli_query($conn, $sql); ?>
<div class="custombox clearfix"> <h4 class="small-title">Comments</h4> <div class="row"> <div class="col-lg-12"> <div class="comments-list" id="commentContainer"> <?php if ($res && mysqli_num_rows($res) > 0) { while ($row = mysqli_fetch_assoc($res)) { $email = $row['cmt_usr_email']; $comments = $row['cmt_usr_msg']; $date = date('d M, Y', strtotime($row['cmt_created_dt'])); ?> <div class="media"> <div class="media-body"> <h4 class="media-heading user_name"><?= htmlspecialchars($email) ?> <small><?= $date ?></small></h4> <p><?= htmlspecialchars($comments) ?></p> </div> </div> <?php } } ?> </div>
<!-- Load More Button --> <div class="text-center mt-3"> <button id="loadMoreBtn" class="btn btn-secondary" data-offset="5" data-article-id="<?= $id ?>">Load More</button> </div> </div> </div> </div>
<hr class="invis1">
<div class="custombox clearfix"> <h4 class="small-title">Leave a Reply</h4> <div class="row"> <div class="col-lg-12"> <form class="form-wrapper" method="post" action="./comments.php"> <input type="hidden" name="email" value="<?= $_SESSION['email'] ?>"> <input type="hidden" name="art_id" value="<?= $id ?>"> <textarea class="form-control" name="comment" placeholder="<?= $_SESSION['email'] != '' ? 'Your Comments' : 'Please Subscribe' ?>" <?= $_SESSION['email'] != '' ? '' : 'Disabled' ?>></textarea> <?= $_SESSION['email'] != '' ? '' : '<a href="#subscribe">Subscribe here</a> </br></br>' ?> <button type="submit" name="submit" class="btn btn-primary">Submit Comment</button> </form> </div> </div> </div> </div><!-- end page-wrapper --> </div><!-- end col -->
<div class="col-lg-3 col-md-12 col-sm-12 col-xs-12"> <div class="sidebar">
<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="<?= $link ?>" 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 src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script> $('#loadMoreBtn').on('click', function() { var button = $(this); var offset = parseInt(button.data('offset')); var articleId = button.data('article-id');
$.ajax({ url: 'load_comments.php', type: 'POST', data: { offset: offset, article_id: articleId }, success: function(response) { if ($.trim(response) != '') { $('#commentContainer').append(response); button.data('offset', offset + 5); } else { button.hide(); // hide button if no more comments } } }); }); </script>
|