<?php 
include 'header.php';

  if (isset($_GET['del'])) {
    $tid = $_GET['del'];
    $del = mysqli_query($link, "DELETE FROM transaction WHERE id = '$tid' ");
    if($del){
       echo "<script>alert('Transaction deleted successfully');window.location.href = 'approved-trans.php' </script>";
    }
  }
?>

<!-- Card start -->
     <div class="card">
                  <div class="card-header">
                    <div class="card-title"></div>
                  </div>
                  <div class="card-body">
                    <div class="table-responsive">
                      <table id="scrollVertical" class="table custom-table">
                        <thead>
                          <tr>
                            <th>#</th>
                            <th>Transaction id</th>
                            <th>Type</th>
                            <th>Coin</th>
                            <th>Amount</th>
                            <th>Status</th>
                            <th>Action</th>
                          </tr>
                        </thead>
                        <tbody>
                 <?php
                      $i = 0;
                            $select = mysqli_query($link, "SELECT * FROM  transaction  WHERE status = 'Approved' ");
                            if (mysqli_num_rows($select) > 0) {
                                while ($row = mysqli_fetch_assoc($select)) {
                                $id = $row ['id']; 
                      $i++         
                   ?>  
                        <tr>
                            <td><?php echo $i  ?></td>
                            <td><?php echo $row['transactionid'] ?></td>
                            <td><?php echo $row['type'] ?></td>
                            <td><?php echo $row['coin'] ?></td>
                            <td><?php echo $row['amount'] ?> USD</td>
                            <td><?php echo $row['status'] ?></td>
                            <td>
                                <a href="?del=<?php echo $row['id'] ?>" class="btn btn-danger">Delete</a>
                            </td>
                        </tr>
                        
                      <?php }} ?>
                      </tbody>
                  </table>
              </div>
          </div>
      </div>
  </div>
<?php
    include 'footer.php';
?>