<?php

  if($_GET['delete'] == true){
    $id = $_GET['id'];
    $table = 'slider';
    $wpdb->delete($table, array( 'id' => $id ));
    echo "<script>alert('Delete Successful!');</script>";
  }
  $data = $wpdb -> get_results("SELECT * FROM `slider` ORDER BY id DESC"); 

?>
<div class="container mt-5">
    <h5>Sliders</h5>
    <table class="table table-striped align-middle">
      <thead>
        <tr>
          <th width="30%">Title</th>
          <th width="35%">Description</th>
          <th width="27%">Image</th>
          <th width="8%" class="text-center">#</th>
        </tr>
      </thead>
      <tbody>
      <?php
        foreach ($data as $row) {
      ?>
        <tr>
          <td><?php echo ''.$row->title.''; ?></td>
          <td><?php echo ''.$row->description.''; ?></td>
          <td><img src="<?php echo ''.$row->image.''; ?>" class="w-50" /></td>
          <td>
            <div class="row">
              <div class="col-6"><a href="?page=allslider&edit=true&id=<?php echo ''.$row->id.''; ?>"><span class="dashicons dashicons-edit-large"></span></a></div>
              <div class="col-6"><a href="?page=allslider&delete=true&id=<?php echo ''.$row->id.''; ?>"><span class="dashicons dashicons-trash"></span></a></div>
            </div>
          </td>
        </tr>
      <?php } ?>
      </tbody>
    </table>
</div>