$region="Gulf of Mexico";
$product="vector winds";
$query ="select DISTINCT posting_group_lu.* FROM posting_group_lu, region_geometry, products_lu WHERE";
$query .="(regions_per_area_algorithm.region=region_lu.region) AND (region_lu.description='$region')";
$query .=" AND (region_geometry.area_algorithm_name=regions_per_area_algorithm.area_algorithm_name) ";
$query .=" AND (posting_group_lu.geotag=region_geometry.geotag)";
$query .=" AND ( (posting_group_lu.product=products_lu.product) AND (products_lu.description='$product')";
$query .=" AND (products_per_geometry.product=products_lu.product) AND (posting_group_lu.geotag=products_per_geometry.geotag))";
//End Query
$query .= ";";
$result = pg_Exec($connection, $query);
$numrecords=pg_numrows($result);
print "<b>Total Records: " . $numrecords ."</b><p>";
// Loop over the result set
for($i=0; $i<$numrecords; $i++)
{
// Retrieve the next row as an associative array where the
// column names are used to access elements in the array
$resultRow = pg_fetch_array($result, $i);
// Display the variable named name, separated by paragraphs
$prtresult=pc_array_to_comma_string($resultRow);
print $prtresult."<p>";
print_r($resultRow);
print "<p>";
}