<?php
require_once '../../library/config.php';
require_once '../library/functions.php';
require_once '../library/logged.php';
require_once '../../library/validation.php';


if (isset($_POST['delete_items'])){
	$a = explode(",", htmlPurify($_POST['delete_items']));
	
	foreach ($a  as $id) : 
	$p_id = isNumber(trim($id));
	$sql = mysql_query("select `image` FROM photo WHERE photo_id =".$p_id);
	$row = mysql_fetch_assoc($sql);
	$deleteImage = '../../upload/photos/'.$row['image'];
	unlink($deleteImage);
	
	mysql_query('DELETE FROM photo WHERE photo_id ='.$id);
	endforeach;
}


?>
<b style="color:red;">Photo(s) Deleted!!!!</b>
<script type="text/javascript">
	setTimeout(function(){location.reload()}, 1000);
</script>