File: /home/wekawqug/ndondocup.sisihub.co.tz/recommended.php
<div class="col-lg-4 border-start custom-border">
<?php
$where = '';
$count = 0; // Initialize counter
if(isset($_GET['q'])){
$where = " and md5(p.category_id) = '{$_GET['q']}' ";
}
$news = $conn->query("SELECT p.*,c.category from post_list p inner join category_list c on c.id = p.category_id where status = 1 $where AND p.recommended = 1 order by unix_timestamp(date_published) desc LIMIT 4");
$count = 0; // Initialize counter
if($news->num_rows > 0):
while($row = $news->fetch_assoc()):
// Format date_published to display only the date part (YYYY-MM-DD)
$date_published = date('F j, Y', strtotime($row['date_published']));
$trans = get_html_translation_table(HTML_ENTITIES,ENT_QUOTES);
unset($trans["\""], $trans["<"], $trans[">"], $trans["<h2"]);
$desc = strtr(html_entity_decode($row['content']),$trans);
$desc=str_replace(array("<li>","</li>"), array("",", "), $desc);
// Increment counter
$count++;
// Display border after every 3 results
if($count % 2 == 1 && $count > 1) {
echo '</div><div class="col-lg-4 border-start custom-border">';
}
?>
<!--START DISPLAYING NEWS-->
<div class="post-entry-1">
<a href="./index.php?page=read_news&c=<?php echo md5($row['id']) ?>" data-id = '<?php echo $row['id'] ?>'><img src="assets/uploads/content_images/<?php echo $row['cover_img'] ?>" alt="" class="img-fluid"></a>
<div class="post-meta"><span class="date">recommended</span> <span class="mx-1">•</span> <span><?php echo $date_published ?></span></div>
<h2><a href="./index.php?page=read_news&c=<?php echo md5($row['id']) ?>" data-id = '<?php echo $row['id'] ?>'><?php echo $row['title'] ?></a></h2>
</div>
<?php endwhile; endif;?>
</div>