<?php
	//connection
	include("connection.php");
    include("frames_header.php");
?>

<h2><strong><em>Delete induction.</em></strong> </h2><br>
<center>
<form action="induction-delete3.php" method="post" name="formu" target="_blank">

<?php

	$dev="";
    if(isset($_POST["devstage"]))
		$dev = $_POST["devstage"];
	
	
	if( strlen($dev)<=0 ){
	    print "<center><h2></h2><br>Please select a developmental stage</center>";
		include("frames_footer.php");
	    return;
	}
    
	
	print '<table border="1" cellspacing="0" cellpadding="0" width="99%">';
	print '<tr align="center"><td>&nbsp;</td><td>Inductor</td><td>Induced</td><td>Default fate</td><td>Induced fate</td><td>Comments</td></tr>';

	$requete= "SELECT \"NAME\", \"INDUCTION_ID\", \"INDUCTOR_ID\", \"INDUCED_ID\", \"DEFAULT_FATE\", \"COMMENTS\" FROM \"INDUCTION\", \"ANAT_ENTITY\" WHERE \"DEV_STAGE_ID\"=$dev and \"INDUCTOR_ID\"=\"ANAT_ID\"";
	
	$stmt = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
    $count=0;
	while($row=pg_fetch_array($stmt)){
        ++$count;
		
		$indid=$row["INDUCTION_ID"];
		
		$requete= "SELECT \"NAME\" FROM \"ANAT_ENTITY\" WHERE \"ANAT_ID\"=".$row["INDUCED_ID"];
		$stmt2 = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
		if($row2=pg_fetch_array($stmt2))
		    $name2=$row2["NAME"];

        $indfate="";
		$requete= "SELECT \"FATE\" FROM \"INDUCTION_FATE\" WHERE \"INDUCTION_ID\"=".$indid;
		$stmt2 = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
		while($row2=pg_fetch_array($stmt2))
		    $indfate.=$row2["FATE"]." ";
	
        print '<tr><td><input type="checkbox" name="ind[]" value="'.$indid.'"></td><td>'.$row["NAME"].'</td><td>'.$name2.'</td><td>'.$row["DEFAULT_FATE"].'</td><td>'.$indfate.'</td><td>'.$row["COMMENTS"].'</td></tr>';
		
	}
	
	print '</table><br><br>';
	if($count==0)
	    print '<strong>No match</strong>';
	else
        print '<input name="submit" type="image" src="pictures/button-submit.jpg" onClick="submit">';
?>
</form>
</center>



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