<?php
//setting header to json 
    header("Content-type: application/json");
    $dID = $_POST["id"];  // get internal sensor id from js
    $p = $_POST["p"];
    $iconID = $_POST["i"];
    require '../php/database.php';

    $query = "UPDATE pinsAvailable SET `iconID`='$iconID' WHERE `driverID`='$dID' AND `gpio`='$p'";

    if ($mysqli->query($query) === TRUE) {
        // echo "Widget Visible updated successfully";
    } else {
        // echo "Error updating Widget Visible: " . $mysqli->error;
    }
    
    //execute query
    $result = $mysqli->query($query);

    //loop through the returned data
    $dataWindow = array();
    foreach ($result as $row) {
        $dataWindow[] = $row;
    }
    
    $mysqli->close();

    // $dataWindow = array();
    print json_encode($dataWindow);
?>