<?php
$host = "49.12.125.236";
$user = "patiltec_anand";
$password = "Asd123!@#";
$dbname = "patiltec_loginsystem1"; 
$con = mysqli_connect($host, $user, $password,$dbname);
if (!$con) {
   die("Connection failed: " . mysqli_connect_error());
}
;?>

<?php 
if(isset($_POST['sd_delete'])){

  if(isset($_POST['delete'])){
    foreach($_POST['delete'] as $deleteid){

      $deleteUser = "DELETE from postsbyusers WHERE id=".$deleteid;
      mysqli_query($con,$deleteUser);
     header("refresh:3000; URL=allinoneproccess.php");
    }
  }
 
}
?>



<!DOCTYPE html>
<html>
<head>
<title>allinone</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body{font-family:arial;}
tr:hover{background: linear-gradient(to left, #ccff66 0%, #ffffcc 100%);}
table, th, td{ border:1px solid black;border-collapse: collapse;}
th, td{padding:5px;}
</style>
</head>

<body bgcolor="white" style="width:700px; margin:5px auto; ">


<div class='container' >
<form method='post' action=''>
<input type='submit' value='Delete' name='sd_delete' style="font-size:22px; cursor:pointer; position:fixed;top:5px;"> <br><br>

    <table border='1' id='recordsTable' style='border-collapse: collapse;' >
      <tr style='background: whitesmoke;'>
        <th bgcolor="deepskyblue">Username</th>
        <th bgcolor="lawngreen">Post Title</th>
        <th bgcolor="LightBlue">Image</th>
        <th bgcolor="Khaki">Posted Text</th>
        <th bgcolor="Orange"><center> Action</center></th>
     </tr>

     <?php 
     $query = "SELECT * FROM postsbyusers";
     $result = mysqli_query($con,$query);
     
     while($row = mysqli_fetch_array($result) ){
        $id = $row['id'];
        $username = $row['name'];
        $name = $row['subject'];
        $sdimg = $row['image'];
        $sdpost = $row['image_text'];
     ?>
     <tr id='tr_<?= $id ?>'>
        <td><?= $username ?></td>
        <td><?= $name ?></td>
        <td><a href="<?= "../images/$sdimg" ?>"> <?= $sdimg ?> </a></td> 
        <td><?= $sdpost ?></td>
        <td><center> <input type='hidden' name='id' value='<?= $id ?>'>
        <input type='checkbox' name='delete[]' value='<?= $id ?>' style='height:20px; width:20px;'>  </center></td>
        
                     <!-- checked="checked"  -->
    </tr>
    <?php
    }
    ?>
   </table>
 </form>
</div>



<br><br><br><br>
Reference website:-<br>
https://makitweb.com/delete-multiple-selected-records-with-php/

</body>  
</html> 







<?php
error_reporting(E_ALL);
if(isset($_POST['submit'])) {
    foreach($_POST['file'] as $file) {
        if(isset($file)) {
            if (unlink($file)) {
                echo "Deletet the file: $file<br />";
            } else {
                echo "Didn't manage to delete the file: $file<br />";
            }
        }
    }
}
?>

<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Reload</a></p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p>
Pick the files you want to delete from folder:<br />
<input type="checkbox" name="file[]" value="file1.php" />file1.php<br />
<input type="checkbox" name="file[]" value="file2.php" />file2.php<br />
<input type="checkbox" name="file[]" value="file3.php" />file3.php<br />
<input type="checkbox" name="file[]" value="file4.php" />file4.php<br />
</p>
<p>
<button type="submit" name="submit">Send</button>
<button type="reset" name="reset">Reset</button>
</p>
</form>