<?php 
include "db.php";
$pincode=array();
$pincode =$_GET['pincode'];
$type =$_GET['type'];
$pincode=explode(",",$pincode);

if($type==1){
foreach($pincode as $id) 
{
    	$statement ="DELETE FROM pincode WHERE id=$id";
    	$result=$con->query($statement);
}

if($result)
echo"<script>alert('Selected Pincodes Deleted Successfully...');window.location = 'pincode.php';</script>";
else
echo"<script>alert('Failed To Delete...');window.location = 'pincode.php';</script>";   
}
elseif($type==2)
{
        $statement ="TRUNCATE TABLE pincode";
    	$result=$con->query($statement);
    	
if($result)
echo"<script>alert('All Pincodes Deleted Successfully...');window.location = 'pincode.php';</script>";
else
echo"<script>alert('Failed To Delete...');window.location = 'pincode.php';</script>";   
}
?>