<?
include ("connection.php");

$id=$_GET["id"];

$requete="SELECT \"NAME\",\"SPECIES\" from \"EMBRYO\" where \"EMBRYO_ID\"='$id'";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt);

$name=$row["NAME"];
$name=str_replace("@","_",$name);
$name=str_replace(" ","_",$row["SPECIES"])."_".$name;

//////////header force download ///////////////////////
header("Content-disposition: attachment; filename=$name.$id.CONTACT.txt");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: text/plain\n"); // Surtout ne pas enlever le \n
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
header("Expires: 0");





print "#cell A / cell B / distance µ / contact µ2\n";
print "#devstage=\n";

$requete="SELECT \"CELL_A\",\"CELL_B\",\"DISTANCE\",\"CONTACT\" from \"EMBRYO_NEIGHBOR\" where \"EMBRYO_ID\"='$id'";
$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt))
{

$cella=$row["CELL_A"];
$cellb=$row["CELL_B"];

$requete0="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$cella'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);

$anatAname=$row0["NAME"];

$requete0="SELECT \"NAME\" from \"ANAT_ENTITY\" where \"ANAT_ID\"='$cellb'";
$stmt0=pg_query($c,$requete0);
$row0=pg_fetch_array($stmt0);

$anatBname=$row0["NAME"];


$dist=$row["DISTANCE"];
$contact=$row["CONTACT"];

print "$anatAname\t$anatBname\t$distance\t$contact\n";


}





?> 
