<?php
include "conn.php";

//intval - Get the integer value of a variable
$id=$_GET['id'];

$sql="DELETE FROM item WHERE Item_Name='$id'";
$result=mysqli_query($conn, $sql);

//if unable to execute the query, then give alert message
if(mysqli_affected_rows($conn)<=0)
{
	echo"<script>alert('Unable to delete data!');";
	die ("window.location.href='view.php';</script>");
}

//if able to execute the delete query...display success alert message.
echo "<script>alert('Data deleted!');</script>";
echo "<script>window.location.href='view.php';</script>";

?>
