HEX
Server: LiteSpeed
System: Linux premium313.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User: wekawqug (1662)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/wekawqug/ndondocup.sisihub.co.tz/category.php
<?php 
session_start();
include 'admin/db_connect.php';
$where = '';
if (isset($_GET['cat'])) {
  $category_id = $_GET['cat'];

  $category_news = $conn->query("SELECT p.*,c.category FROM post_list p inner join category_list c on c.id = p.category_id where md5(c.id)='$category_id' AND status = 1 order by unix_timestamp(date_published) desc");
  if($category_news->num_rows > 0):
    //$first_row = $category_news->fetch_assoc();
    //$category = $first_row['category'];

    ?>
    <section style="margin-top:100px">
      <div class="container">
        <div class="row">

          <div class="col-md-9">
            <h3 class="category-title"> <?php echo ''; ?></h3>
            <?php
    while($row = $category_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);
        

?>
    
    

            <div class="d-md-flex post-entry-2 half">
            <a href="./index.php?page=read_news&c=<?php echo md5($row['id']) ?>" data-id = '<?php echo $row['id'] ?>' class="me-4 thumbnail">
                <img src="assets/uploads/content_images/<?php echo $row['cover_img'] ?>" alt="" class="img-fluid">
              </a>
              <div>
                <div class="post-meta"><span class="date"><?php echo ucwords($row['category'] ) ?></span> <span class="mx-1">&bullet;</span> <span><?php echo $date_published ?></span></div>
                <h3><a href="./index.php?page=read_news&c=<?php echo md5($row['id']) ?>" data-id = '<?php echo $row['id'] ?>'><?php echo $row['title'] ?></a></h3>
                <p><?php echo strip_tags($desc) ?></p>
                <div class="d-flex align-items-center author">
                  <div class="photo"><img src="assets/img/person-2.jpg" alt="" class="img-fluid"></div>
                  <div class="name">
                    <h3 class="m-0 p-0">Ndondo Admin</h3>
                  </div>
                </div>
              </div>
            </div>
            <?php    endwhile;    endif;?>

            

            <div class="text-start py-4">
              <div class="custom-pagination">
                <a href="#" class="prev">Prevous</a>
                <a href="#" class="active">1</a>
                <a href="#">2</a>
                <a href="#">3</a>
                <a href="#">4</a>
                <a href="#">5</a>
                <a href="#" class="next">Next</a>
              </div>
            </div>
          </div>

          <div class="col-md-3">
          <?php include 'sidebar.php' ?>

          </div>

        </div>
      </div>
    </section>
<?php } 
else {
  $category_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 order by unix_timestamp(date_published) desc");
  if($category_news->num_rows > 0):
 
    ?>
    <section style="margin-top:100px">
      <div class="container">
        <div class="row">

          <div class="col-md-9">
            <h3 class="category-title">Category: All</h3>
            <?php
    while($row = $category_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);
   ?>
  <div class="d-md-flex post-entry-2 half">
            <a href="./index.php?page=read_news&c=<?php echo md5($row['id']) ?>" data-id = '<?php echo $row['id'] ?>' class="me-4 thumbnail">
                <img src="assets/uploads/content_images/<?php echo $row['cover_img'] ?>" alt="" class="img-fluid">
              </a>
              <div>
                <div class="post-meta"><span class="date"><?php echo ucwords($row['category'] ) ?></span> <span class="mx-1">&bullet;</span> <span><?php echo $date_published ?></span></div>
                <h3><a href="./index.php?page=read_news&c=<?php echo md5($row['id']) ?>" data-id = '<?php echo $row['id'] ?>'><?php echo $row['title'] ?></a></h3>
                <p><?php echo strip_tags($desc) ?></p>
                <div class="d-flex align-items-center author">
                  <div class="photo"><img src="assets/img/person-2.jpg" alt="" class="img-fluid"></div>
                  <div class="name">
                    <h3 class="m-0 p-0">Ndondo Admin</h3>
                  </div>
                </div>
              </div>
            </div>
            <?php    endwhile;    endif;?>

            

            <div class="text-start py-4">
              <div class="custom-pagination">
                <a href="#" class="prev">Prevous</a>
                <a href="#" class="active">1</a>
                <a href="#">2</a>
                <a href="#">3</a>
                <a href="#">4</a>
                <a href="#">5</a>
                <a href="#" class="next">Next</a>
              </div>
            </div>
          </div>

          <div class="col-md-3">
          <?php include 'sidebar.php' ?>

          </div>

        </div>
      </div>
    </section>
    <?php }?>