<?php
include("db.php");

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <title>Driver Logbook</title>
    <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/fonts/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/Registration-Form-with-Photo.css">
    <link rel="stylesheet" href="assets/css/styles.css">
</head>
<div class="login-clean" style="height: 760px;background-image: url(&quot;assets/img/star-sky.jpg&quot;);">
  <div class="form-container" style="padding-top:60px">
  <div class="card" style=" max-width:900px; width:80%; margin:auto; border-radius:20px;">
  <div class="card-header">
    <?php
    $name = mysqli_query($conn, "SELECT username from users where username='$_POST[username]'");
    $get = mysqli_fetch_array($name);
    ?>
    <h5 class="mb-0" style="text-align:left;"><?php echo $get['username']?>'Profile</h5>

  </div>
  <div class="card-body" style="height:480px; overflow-y:scroll; overflow-x:hidden;">
    <table class="table table-striped" >
      <tr>
        <th>Car Used</th><th>Client</th><th>Job/Employee Number</th><th>Start Mileage</th><th>End Mileage</th><th>Distance travelled</th>
      </tr>
    <?php  $result = mysqli_query($conn, "SELECT car,client,job,start_mileage,end_mileage FROM trips WHERE username='$_POST[username]'ORDER BY id DESC");
    while($row = mysqli_fetch_array($result)){
    $mileage = $row['end_mileage'] - $row['start_mileage'];?>
    <div style="overflow-y:scroll; overflow-x:hidden;">
      <tr>
        <td><?php echo $row['car'];?></td>
        <td><?php echo $row['client'];?></td>
        <td><?php echo $row['job'];?></td>
        <td><?php echo $row['start_mileage'];?></td>
        <td><?php echo $row['end_mileage'];?></td>
        <td><?php echo $mileage;?></td>
        <?php
      }?>
      </tr>
</div>
    </table>


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

</html>
