<?php

error_reporting(E_ERROR | E_PARSE);
// sql data connection 

$DB_Host = "localhost";
$DB_Name = "mrcode_FMdatabase";
$DB_Table = "workingOrder";
$DB_User = "mrcode_User";
$DB_Pass = "o;1fT@L+cB&P";


$forgeid =  $_GET['forgeid'];
$week =     $_GET['week'];
$urn =      $_GET['urn'];

if($forgeid != null && $week != null){
    
    
// connect to sql 
$conn = new mysqli($DB_Host, $DB_User, $DB_Pass,$DB_Name);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// get data of element


    $sql = "DELETE FROM `workingOrder` WHERE `forge_id`= $forgeid AND `week` = $week AND `urn` = '$urn' ";
    if ($conn->query($sql) === TRUE && $conn -> affected_rows > 0) {
        
        $myObj->deleted = "OK";
        $myArray[] = $myObj;
        $myJSON = json_encode(array('workingOrder' =>$myArray));
        echo $myJSON;
        
    } 
    else {
        
        $myObj->deleted = null;
        $myArray[] = $myObj;
        $myJSON = json_encode(array('workingOrder' =>$myArray));
        echo $myJSON;
    }
    

    


$conn->close();


}
else{
    
    $myObj->deleted = null;
        $myArray[] = $myObj;
        $myJSON = json_encode(array('workingOrder' =>$myArray));
        echo $myJSON;
}

?>
