<?php
	session_start();
	
	include("config.php");
	
	$id_gallery=mysqli_real_escape_string($mysqli, $_GET["id"]);
	$idx=mysqli_real_escape_string($mysqli, $_GET["id"]);
	
	//menghapus data di tabel m_gallery
	$sql="DELETE FROM m_gallery WHERE id_gallery='$id_gallery'";
	
	$qry=mysqli_query($mysqli,$sql);
	
	//mulai menghapus file-file foto di album ini
	$sqlx="SELECT * FROM t_gallery WHERE id_gallery='$id_gallery'";
	$qryx=mysqli_query($mysqli, $sqlx);
	while($dtx=mysqli_fetch_array($qryx)){
		$nm_file="../foto_berita/" . $dtx["file_foto"];
		unlink($nm_file);
	}	
	
	//menghapus foto-foto di t_gallery
	$sqlx="DELETE FROM t_gallery WHERE id_gallery='$id_gallery'";
	$qryx=mysqli_query($mysqli, $sqlx);
	
	if($qry){
		msgbox("Album gallery berhasil dihapus...");
		
		lempar("admin.php?page=ls_album&page_desc=Kelola%20Album");
	}else{
		
		msgbox("Error: ".mysqli_error($mysqli));
		lempar("admin.php?page=ls_album&page_desc=Kelola%20Album");
	}
?>