<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<?php
		include("connect.php");
		session_start();
		$imgid = $_SESSION['imgid'];
		$strSQL1 = "SELECT * FROM gallery WHERE GalleryID = '".$_GET["GalleryID"]."' ";
		$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
		$objResult1 = mysql_fetch_array($objQuery1);
		$imgid = $objResult1['Gadget_id'];
		//*** Select Old File ***//
		$strSQL = "SELECT * FROM gallery WHERE GalleryID = '".$_GET["GalleryID"]."' ";
		$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
		$objResult = mysql_fetch_array($objQuery);

		//*** Delete File ***//			
		@unlink("myfile/".$objResult["GalleryShot"]);
		
		//*** Delete Row ***'
		$strSQL = " DELETE FROM gallery WHERE GalleryID = '".$_GET["GalleryID"]."' ";
		$objQuery = mysql_query($strSQL);		
		echo"<script language='JavaScript'>";
		echo"alert('ลบรูปภาพเสร็จสิ้น');";
		echo"</script>";		
		echo "<meta http-equiv='refresh' content='0;url=editimg.php?img_id=$imgid '/>";
		
		mysql_close($objConnect);
?>
</body>
</html>