<?php
include("connection.php");
include("frames_header.php");
?>
<html>
<body bgcolor="#871F1F" text="#FFFFFF" link="#000000" vlink="#000000" alink="#000000">
<title>ANISEED</title>
<center>
<?php



	
	$count=0;
    if(isset($_POST["count"]))
		$count = $_POST["count"];
	
	for($i=0;$i<$count-1;++$i){
        
	    $region=$_POST["region$i"];

		$j=$i+1;
		$parent=$_POST["region$j"];
		
		//print "$parent - $region<br>";
	    
		
		$requete2="select * from \"LINEAGE\" where (\"MOTHER_CELL\"=$parent) and (\"DAUGHTER_CELL\"=$region)";
		//print $requete2;
		$stmt2 = pg_query($c,$requete2) or die("<strong>Error</strong> ".pg_last_error($c));
	    if(! $row2=pg_fetch_array($stmt2)){
			$requete="insert into \"LINEAGE\" (\"MOTHER_CELL\", \"DAUGHTER_CELL\") values($parent,$region)";
			pg_query($c,"begin");
			$stmt3 = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
			pg_query($c,"commit");
		}
		
	}
	print "Data successfully entered";
	
	
?>

<br><br><br>
<input type="button" name="OK" onClick="javascript: self.close();" value=" OK ">
</center>
</body>
</html>

<?
include ("frames_footer.php");
?>

