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

foreach ($_POST as $paramName => $paramValue) {
  if ($paramName == "checkval")
    $name = $paramValue;
  else if ($paramName == "filterid")
    $pa_id = $paramValue;
}

$dal = new DAL();

$sql = "SELECT PF.id, FO.name " . 
       "FROM parcelfop PF, fop FO " .
       "WHERE PF.parcel_id = $pa_id AND FO.id = PF.fop_id " . 
       "AND FO.name = '$name' ";
$result = $dal->query($sql);

if (null == $result)
  $next_fop_name = $name;
else
  $next_fop_name = "";

echo json_encode($next_fop_name);

?>

