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

<?php
    $species="";
	if (isset($_GET["species"])) $species=$_GET["species"];

	if( (isset($_GET["species"])) and (strlen($species)>0) ){
		$query="SELECT \"NAME\", \"DEV_STAGE_ID\" FROM \"DEV_STAGE\" WHERE \"SPECIES\"='$species' ORDER BY \"DEV_PERCENT\"";
		$stmt = pg_query($c,$query) or die("<strong>Error</strong> ".pg_last_error($c));
	}



/*
	include("connection.php");
	
	if( (isset($_GET["species"])) and (strlen($species)>0) ){
		$requete = "SELECT DISTINCT NAME FROM CIONA_DESIGN.ANAT_ENTITY WHERE (SPECIES='$species') AND (TYPE!='cell') ORDER BY NAME";
		$resultset = OCIParse($connection, $requete);
		OCIExecute($resultset);
	}
*/
	
?>

<h2><strong><em>Anatomical dictionnary search.</em></strong> </h2>
<center>
<form name="formulaire" action="anatomy-to-fate.php" method="get" target="_blank">
	<table width="99%" border="0" cellspacing="0" cellpadding="0" background="pictures/barre.jpg">
      <tr bgcolor="#990000"> 
        <td></td>
        <td></td>
        <td></td>
        <td align="right" background="pictures/barre-red.jpg"><em><strong>Anatomical 
          dictionary</strong></em></td>
      </tr>
      <tr> 
        <td align="right"><br> <br> <br> <strong>Species</strong></td>
        <td align="left"> <br> <br> <br> <select name="species" size="1" onChange="self.location.href = 'anatomy-search.php?species=' + this.options[ this.selectedIndex ].value">
            <option ></option>
            <?php
			
				$requete = "select \"NAME\" from \"SPECIES\" ";
				$stmt0 = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
				while ($row0=pg_fetch_array($stmt0))
				{
					$name = $row0["NAME"];
					print "<option value=\"$name\"";
					if($species==$name)
					    print " selected";
					print ">$name</option>";
				}
				
		   ?>
			
          </select> </td>
        <td align="right"><br> <br> <br> <strong>Developmental stages:</strong></td>
        <td align="left"> <br> <br> <br> 
		    <select name="dev" size="10">
            <option>_________________________</option>
            <?php
						 $id="";
						 while($row=pg_fetch_array($stmt))
						 {
							print "<option value=\"".$row["DEV_STAGE_ID"]."\">";
							print $row["NAME"]."</option>\n";
							
							$id .= $row["DEV_STAGE_ID"].":";
						 }
					  	?>
          </select> </td>
      </tr>
      <tr>
        <td valign="top"><hr color="#871F1F" size="1"></td>
        <td valign="top"><hr color="#871F1F" size="1"></td>
        <td valign="top"><hr color="#871F1F" size="1"></td>
        <td valign="top"><hr color="#871F1F" size="1"></td>
      </tr>
      <tr> 
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td align="right"><strong>Displayed fates: </strong></td>
        <td align="left">
		    <select name="fate[]" size="10" multiple>
            <?php
				 $requete= "SELECT \"KEYWORDS\" from \"FATE_KW\" order by \"KEYWORDS\"";
				 $stmt = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
				 while($row=pg_fetch_array($stmt))
					print "<option value=\"".$row["KEYWORDS"]."\">".$row["KEYWORDS"]."</option>\n";
			?>
          </select>
		</td>
      </tr>
      <tr> 
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td align="right"> <br> <br> <input name="submit" type="image" src="pictures/button-submit.jpg" onClick="submit"> 
          &nbsp;&nbsp;&nbsp; <br> </td>
      </tr>
    </table>

</form>
</center>

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