<?php

require_once($_SERVER['DOCUMENT_ROOT'] . '/sys/db.php');

$child = ""; 
foreach ($_POST as $paramName => $paramValue) {

  if ($paramName == "table")
    $table = $paramValue;
  elseif ($paramName == "rowid") 
    $id = $paramValue; 
  elseif ($paramName == "child") {
    $child = $paramValue;  
    $child_fk = $table + "_id";
  }  
}

$dal = new DAL();

$sql = "UPDATE $table SET active=0 WHERE id = $id ";
$result = $dal->query($sql);

if ($child != "") {
  $sql = "UPDATE $child SET active=0 WHERE $child_fk = $id ";
  $result = $dal->query($sql);
}  

echo json_encode($result);

?>

