<?php 
	$conn = mysqli_connect("49.12.125.236","patiltec_anand","Asd123!@#","patiltec_loginsystem1");
	if(!$conn)
	{
		die(mysqli_error());
	}

	$sql = "select * from postsbyusers";
	$rs = mysqli_query($conn, $sql);

	if(isset($_GET['deleteid']))
	{
		$selectSql = "select * from postsbyusers where id = ".$_GET['deleteid'];
		$rsSelect = mysqli_query($conn,$selectSql);
		$getRow = mysqli_fetch_assoc($rsSelect);
		
		$getIamgeName = $getRow['image'];
		
		$createDeletePath = "../images/".$getIamgeName;
		$createDeletePath2 = "../images/thumbs/".$getIamgeName;
		
		if(unlink($createDeletePath))
		if(unlink($createDeletePath2))
		{
			$deleteSql = "delete from postsbyusers where id = ".$getRow['id'];
			$rsDelete = mysqli_query($conn, $deleteSql);	
			
			if($rsDelete)
			{
				header('location:index.php?success=true');
				exit();
			}
		}
		else
		{
			$errorMsg = "Unable to delete Image";
		}
		
	}
 
	
?>
 
<!DOCTYPE html>
<html>
<head>
<title>REBUTTON.PHP</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >

<style>
@media only screen and (max-width: 600px) {
body { width:100%;}
img { width:110px;}
}
</style>
</head>
 
<body>
	<div class="container">
		<h3 class="text-center">Thumbs and Images and Post Delete </h3>
		
		<div class="row">
		
		<?php 
		if(isset($errorMsg))
		{
		?>
			<div class="alert alert-danger">
				<?php 
					echo $errorMsg;
					unset($errorMsg);
				?>
			</div>
		<?php 
		}
		?>
		
		<?php 
		if(isset($_GET['success']) && $_GET['success'] == 'true')
		{
		?>
			<div class="alert alert-success">
				<?php 
					echo "Images has been deleted sucessfully";
				?>
			</div>
		<?php 
		}
		?>
		
		
	<?php 
		while($row = mysqli_fetch_assoc($rs))
		{
			$imgWithPath = "../images/thumbs/".$row['image'];
			$imgWithPath2 = "../images/".$row['image'];
		?>	

			<div class="col-md-1 text-center" style="background-color:#e6ffff; float:left; margin:4px; padding:0 0 6px 0; border:1px solid black; border-radius:8px;">
				<a href="<?php echo $imgWithPath2 ?>"><img src="<?php echo $imgWithPath ?>" width="75" height="75" vspace='5px'> </a><br>
				<a href="?deleteid=<?php echo $row["id"]?>" class="btn btn-primary border">Delete</a>
			</div>
			
			
	<?php		
		}
		
	?>
	
	</div>
	</div>

refer:-
https://www.wdb24.com/php-remove-file-from-folder-and-database/
	
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>	
</body>
</html>

