<?php
require('db.php');
include "x.php";
?>
<!doctype html>
<html lang="en">
  <head>
    
     <?php include "include/meta.php"; ?>

     <?php include "include/css.php"; ?>

       <link rel="stylesheet" href="assets/css/bootstrap.css">
<style>
  td{
    padding: 10px 10px;
  }
   .center{
    text-align: center;
  }
</style>
  </head>
  <body>
<?php include "include/header.php"; ?>


 <?php 


        if (isset($_GET['pageno'])) {
            $pageno = $_GET['pageno'];
        } 
        else {
            $pageno = 1;
        }
        $no_of_records_per_page = 10;
        $offset = ($pageno-1) * $no_of_records_per_page;



        $total_pages_sql = "SELECT COUNT(*) FROM notice_table";
        $result = mysqli_query($con,$total_pages_sql);
        $total_rows = mysqli_fetch_array($result)[0];
        $total_pages = ceil($total_rows / $no_of_records_per_page);
   ?>

<section class="w3l-contact-breadcrum">
  <div class="breadcrum-bg py-sm-5 py-4">
    <div class="container py-lg-3">
      <h2>Notice</h2>
      <p><a href="index.php">Home</a> &nbsp; / &nbsp; Notice</p>
    </div>
  </div>
</section>


<div class="container">
  <div class="row">
        <div class="col-md-1">
      



    </div>
    <div class="col-md-10">
      <br>
<div class="well form-horizontal">

            
  <p align="left"><table width="98%" border="1" cellspacing="3" cellpadding="3" bordercolor="#000000" style="border-collapse:collapse;">
           <tr align="center" style="background:grey; border:1px solid #000; color:#fff;">
            <td  colspan="4" style="co lor: black; padding: 20px 0; font-size: 20px; ">Notice Board</td>
           </tr>
           <tr align="center" style="background:#990000; border:1px solid #000; color:#fff;">
           
            <td align="left">&nbsp;&nbsp;&nbsp;Recent updates</td>
           </tr>

           <?php
                                                   
                $sql = "SELECT * FROM notice_table WHERE n_by = '$x' AND type = 'notice' ORDER BY n_date DESC LIMIT $offset, $no_of_records_per_page";
                $res_data = mysqli_query($con,$sql);
                $c = 1;
                while($rows = mysqli_fetch_array($res_data))
               { 

            ?>
                                                                                                 
           <tr class="text_col">
            <td align="left"><a href="notice_total.php?n=<?php echo $rows['n_sl']; ?>" target="_blank" style="text-decoration:none;">  <?php echo $rows['n_title']; ?></a>
              <br>
              <p>&#8195;<?php echo showDate($rows['n_date']); ?>
               &nbsp;<?php echo showTime($rows['n_time']); ?></p>


            </td>
            </tr>
           
           <?php 
              $c++;
                }
            ?>
           
          </table></p>
    <ul class="pagination">
        <li><a href="?pageno=1">First</a></li>
        <li class="<?php if($pageno <= 1){ echo 'disabled'; } ?>">
            <a href="<?php if($pageno <= 1){ echo '#'; } else { echo "?pageno=".($pageno - 1); } ?>">Prev</a>
        </li>
        <li class="<?php if($pageno >= $total_pages){ echo 'disabled'; } ?>">
            <a href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?pageno=".($pageno + 1); } ?>">Next</a>
        </li>
        <li><a href="?pageno=<?php echo $total_pages; ?>">Last</a></li>
    </ul>

        



</div>

    </div>
    <div class="col-md-1">
      



    </div>
  </div>
</div>

<?php include "include/footer.php"; ?>
<?php include "include/js.php"; ?>

</body>

</html>
<!-- // grids block 5 -->

<?php 

     function showDate($dt) 
     {
          $date=date_create();
          date_timestamp_set($date,
          strtotime("$dt"));
          return date_format($date,"M j, Y");
    }

    function showTime($t) 
     {
          $time=date_create();
          date_timestamp_set($time,
          strtotime("$t"));
          return date_format($time,"g:i a");
    }

 ?>