<table cellpadding="0" cellspacing="0" border="0">
  <tbody>
    <?php

      session_start();
      //Connect to database
      require'connectDB.php';

      if (isset($_POST['log_date'])) {
        if ($_POST['date_sel'] != 0) {
            $_SESSION['seldate'] = $_POST['date_sel'];
        }
        else{
            $_SESSION['seldate'] = date("Y-m-d");
        }
      }
      
      if ($_POST['select_date'] == 1) {
          $_SESSION['seldate'] = date("Y-m-d");
          $seldate = $_SESSION['seldate'];
      }
      else if ($_POST['select_date'] == 0) {
          $seldate = $_SESSION['seldate'];
      }

      $sql = "SELECT *,TIME(tgl1) as waktuin,TIME(tgl2) as waktuot FROM data_logs WHERE tgl='$seldate' ORDER BY id DESC";
      // echo $sql;
      $result = mysqli_stmt_init($conn);
      if (!mysqli_stmt_prepare($result, $sql)) {
          echo '<p class="error">SQL Error</p>';
      }
      else{
        mysqli_stmt_execute($result);
          $resultl = mysqli_stmt_get_result($result);
        if (mysqli_num_rows($resultl) > 0){
            while ($row = mysqli_fetch_assoc($resultl)){
      ?>

      <tr>
      <td><?php echo $row['username1'];?></td>
      <td><?php echo $row['idrfid'];?></td>
      <td><?php echo $row['tgl'];?></td>
      <td><?php echo $row['waktuin'];?></td>
      <td><img src="images/photos/<?php echo $row['photo1'];?>" width="100px"></td>
      <td><?php echo $row['waktuot'];?></td>
      <td><img src="images/photos/<?php echo $row['photo2'];?>" width="100px"></td>      
      </tr>

    <?php
            }   
        }
      }
    ?>
  </tbody>
</table>
