<?php
if (isset($_POST['id_delete'])) {
	if(settype($_POST['id_delete'], 'integer')) $id_delete = $_POST['id_delete'];
} else $id_delete = 0;

if ($id_delete){
	$sql = "SELECT label FROM ".$module." WHERE id = :id ";
	
	$result = $conn->prepare($sql);
	$result->bindValue(':id', $id_delete, PDO::PARAM_INT);
	$result->execute();
	
	if ($result->rowCount()){
		$arr = $result->fetch();
		
		$sql = "DELETE FROM ".$module." WHERE BINARY label = :label ";
		$result = $conn->prepare($sql);
		$result->bindValue(':label', $arr['label'], PDO::PARAM_STR);
		$result->execute();
		
	}
	$id_delete = 0;
}

if (isset($_POST['multi_delete']) && $_POST['multi_delete']){
	if (isset($_POST['c_check'])){
		foreach ($_POST['c_check'] AS $check_id => $value){
			$sql = "SELECT label FROM ".$module." WHERE id = :id ";
			
			$result = $conn->prepare($sql);
			$result->bindValue(':id', $check_id, PDO::PARAM_INT);
			$result->execute();
			
			if ($result->rowCount()){
				$arr = $result->fetch();
				
				$sql = "DELETE FROM ".$module." WHERE BINARY label = :label ";
				$result = $conn->prepare($sql);
				$result->bindValue(':label', $arr['label'], PDO::PARAM_STR);
				$result->execute();
				
			}
		}
	}
}


print "
<input type='hidden' name='id_delete' value='".$id_delete."' />
<input type='hidden' name='multi_delete' value='0' />";