<?php

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

$theme = $settings["theme"];

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

require admin_view('sponsor-listele');