Location: PHPKode > projects > EZphotopress > ezphotopress-1.0.0/admin/projects/deleteProject.php
<h3><?=DELETEPROJECT_TITLE?></h3>
<?php
if (isset($pid) && $pid != "" && $pid > 0 && is_numeric($pid)) {
	//get category data
	$queryName = $db->query("select * from ".TABPREFIX."projects where id=".$pid);
	$rowName = $queryName->fetch();
	
	//get images path
	$thumb = $rowName['path_thumb'];
	$img = $rowName['path_img'];
	
	//delete project
	$msg = "";
	$continue = 1;
	$result = $db->query("delete from ".TABPREFIX."projects where id=".$pid);
	if ($result->sizeIDU() != -1) {
		$msg = DELETEPROJECT_MESSAGE_SUCCESS_1.strtoupper($rowName['title']).DELETEPROJECT_MESSAGE_SUCCESS_2;
	} else {
		$msg = DELETEPROJECT_MESSAGE_ERROR_1.strtoupper($rowName['title']).DELETEPROJECT_MESSAGE_ERROR_2;
		$continue = 0;
	}
	
	//continue to remove the images only if the project is deleted otherwise no
	if ($continue == 1) {
		//try to detele the thumbnail
		if (isset($thumb) && $thumb != "") {
			try {
				@unlink("../".$thumb);
				$msg .= DELETEPROJECT_THUMBNAIL.$thumb.DELETEPROJECT_SUCCESS;
			} catch (Exception $e) {
				$msg .= DELETEPROJECT_THUMBNAIL.$thumb.DELETEPROJECT_ERROR;
			}
		}
		
	    //try to detele the image
		if (isset($img) && $img != "") {
			try {
				@unlink("../".$img);
				$msg .= DELETEPROJECT_IMAGE.$img.DELETEPROJECT_SUCCESS;
			} catch (Exception $e) {
				$msg .= DELETEPROJECT_IMAGE.$img.DELETEPROJECT_ERROR_;
			}
		}
	}
	?>
	<p class="ok"><?php echo $msg; ?></p>
	<br>
	<br>
	<br>
	<center>
		<a href="home.php?id=projects&action=manage&type=d" class="back"><?=DELETEPROJECT_LINK_CONTINUE?></a>
	</center>
<?php
}
?>
Return current item: EZphotopress