<?php

$query=$db->prepare("SELECT * FROM haberler order by id ASC");
$query->execute();

$theme = $settings["theme"];

if(isset($_POST["deletehaber"])){
	$delproduct = $_POST["deletehaber"];
	foreach($delproduct as $deletehaber){
		$sor = $db->prepare("SELECT * FROM haberler WHERE id=:id");
		$sor->execute(array(
			'id' => $deletehaber
		));
		$cek=$sor->fetch(PDO::FETCH_ASSOC);
		$image=PATH . "/public/{$theme}/{$cek['image']}";
		$delete = $db->prepare("DELETE FROM haberler WHERE id = ?");
		$delete->execute(array($deletehaber));
		if($delete){
			@unlink("$image");
			$success = 'İşlem başarıyla gerçekleşti.';
		}else{
			$error = 'Bir hata oluştu.';
		}
	}
}

require admin_view('haber-listele');