<?php

	require_once 'dbconfig4.php';
	
	if(isset($_GET['adid']))
	{
		
		$stmt_select = $DB_con->prepare('SELECT image FROM investadvertisments WHERE adid =:adid');
		$stmt_select->execute(array(':adid'=>$_GET['adid']));
		$imgRow=$stmt_select->fetch(PDO::FETCH_ASSOC);
		unlink("images/advertisments/".$imgRow['image']);


		$stmt_delete = $DB_con->prepare('DELETE FROM investadvertisments WHERE adid =:adid');
		$stmt_delete->bindParam(':adid',$_GET['adid']);
		$stmt_delete->execute();

		echo"<script type='text/javascript'>window.location.href = 'advertisments.php';</script>";
		
	}

?>