<?php
	session_start();
	
	include("config.php");
	
	$id_gallery=mysqli_real_escape_string($mysqli, $_GET["id_gallery"]);
	$idx=mysqli_real_escape_string($mysqli, $_GET["id"]);
	
	$sqlx="SELECT * FROM t_gallery WHERE idx='$idx'";
	$qryx=mysqli_query($mysqli, $sqlx);
	$dtx=mysqli_fetch_array($qryx);
	
	$nm_file="../foto_berita/" . $dtx["file_foto"];
	
	$sql="DELETE FROM t_gallery WHERE idx='$idx'";
	
	$qry=mysqli_query($mysqli,$sql);
	
	if($qry){
		if(!unlink($nm_file)){
			msgbox("File foto gagal dihapus...");
		}else{
			msgbox("File foto berhasil dihapus...");
		}
		
		lempar("admin.php?page=ls_gallery&id_gallery=$id_gallery");
	}else{
		
		msgbox("Error: ".mysqli_error($mysqli));
		lempar("admin.php?page=ls_gallery&id_gallery=$id_gallery");
	}
?>