<?php

	require_once 'dbconfig.php';
	
	if(isset($_GET['dmid']))
	{
		$stmt_select = $DB_con->prepare('SELECT image FROM mobiledailymeters WHERE dmid =:dmid');
		$stmt_select->execute(array(':dmid'=>$_GET['dmid']));
		$imgRow=$stmt_select->fetch(PDO::FETCH_ASSOC);
		unlink("images/dailymeters/".$imgRow['image']);
		
		$stmt_delete = $DB_con->prepare('DELETE FROM mobiledailymeters WHERE dmid =:dmid');
		$stmt_delete->bindParam(':dmid',$_GET['dmid']);
		$stmt_delete->execute();

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

?>