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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "selectid")
	$ca_id = $paramValue;
}

if ($ca_id > 0) {
  $dal = new DAL();
  $sql = "SELECT id,       controlfield_id AS id_attr, " .
         "controlfield_id, 0 AS controlfield_id_attr, " . 
         "attribute,  attribute AS attribute_attr, " .
         "value,     value AS value_attr " .
         "FROM controlattr " .
         "WHERE id = $ca_id LIMIT 1 " ;
  $result = $dal->query($sql);
}

$_SESSION['controlattr'] = $ca_id;

echo json_encode($result);

?>

