<?php

//--------------------------------------------------------------------------------------------------
// This script reads event data from a JSON file and outputs those events which are within the range
// supplied by the "start" and "end" GET parameters.
//
// An optional "timeZone" GET parameter will force all ISO8601 date stings to a given timeZone.
//
// Requires PHP 5.2.0 or higher.
//--------------------------------------------------------------------------------------------------

// Require our Event class and datetime utilities
require dirname(__FILE__) . '/utils.php';

    //database details
    $dbHost     = 'localhost';
    $dbUsername = 'root';
    $dbPassword = '';
    $dbName     = 'prenotazioni';

    //create connection and select DB
    $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
    if($db->connect_error){
        die("Unable to connect database: " . $db->connect_error);
    }

	// print_r($_GET);
	// exit(0);
	
	$id  = $_GET['id'];
	
	// echo "ID: " . $id;
	// exit(0);

	$data = array();

	$data['result'] = 0;
	$sql    = "delete from test where id = ? ";
	$stmt   = $db->prepare($sql);
	$stmt->bind_param('d', $id);
	if($stmt->execute()){
		$data['result'] = 1;
	}	
	// echo "<br>RES: ".$result;
	$json = json_encode($data);
	echo $json;
