<?php
//include("../../database.inc.php"); //database.inc.php is databse connection file which will be included
include("../../../include/startup.php"); 
ob_clean();
if(isset($_REQUEST['action']) && $_REQUEST['action']=='delete_station_detail'){
	$station_detail_id = $_REQUEST['station_detail_id'];
	mysqli_query($conn,"DELETE FROM station_detail_table WHERE id = '$station_detail_id' ");
	$returnArray["status"] = "success";
	echo json_encode($returnArray);
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='check_station_exist'){
	$station = $_REQUEST['station'];
	$station = mysqli_real_escape_string($conn, $station);
	$id = $_REQUEST['id'];
	$where = "";
	if(isset($id) && $id !=""){
		$where = " AND id != '$id' ";
	}
	$returnArray = array();
	$sql = "SELECT * FROM station_master_table WHERE station = '$station' $where ";
	$rs = mysqli_query($conn,$sql);
	if(mysqli_num_rows($rs) > 0){
		$row = mysqli_fetch_assoc($rs);
		$returnArray['status'] = "failure";
	}else{
		$returnArray['status'] = "success";
	}
	echo json_encode($returnArray);	
}
die;
?>