<?php
session_start();
include 'myfunctions.php';
 
       $id=$_GET['id'];
 $location=$_GET['loc'];
    $query="SELECT * FROM images WHERE image_id=".$id ;
 
  $result = mysqli_query($conn, $query);
      $rs = mysqli_fetch_assoc($result);
$location = $rs['location'];

  if (!$location=="") { 
       unlink ($location);
  }
  
  $sql="DELETE FROM images WHERE image_id=".$id;
  
 if ($conn->query($sql) === TRUE) {
	     //echo "<script> alert('Record deleted successfully');</script>";	
	} else {
	   //echo "<script> alert('Error deleting record:');</script>"
	  // echo "Error deleting record: " . $conn->error;
	}	 
 
//$myVal  = "image_id=$id\n";
//$myVal .= "location=$location\n";
//$myVal .= "error=$conn->error\n";
 
//echo  trim($myVal) ;
	
?>

<script language="JavaScript" type="text/JavaScript">
  window.history.back();
  location.reload();
</script>