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


<center>

<form name="formulaire" action="competence2.php" method="post" target="_blank">

	        <table width="99%" border="0" cellspacing="0" cellpadding="0" background="pictures/barre.jpg">
              <tr bgcolor="#990000"> 
                <td>&nbsp;</td>
				<td>&nbsp;</td>
                <td align="right" background="pictures/barre-red.jpg"><em><strong>Competence</strong></em></td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
                <td>&nbsp;</td>
				<td>&nbsp;</td>
              </tr>
			  
              <tr> 
                
				<td align="center" valign="top">
				    <strong>Species</strong>
				    <!--
					<select name="species" size="1" onChange="javascript: self.location.href = 'fate-search.php?species=' + this.options[ this.selectedIndex ].value;">
					-->
					<br>
					<select name="species" size="1" onChange="javascript: document.forms[0].action='competence.php'; document.forms[0].target='_self'; submit();">
						<option></option>
						<?php
							$species="";
							if (isset($_POST["species"])) $species=$_POST["species"];
							
							$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="center" valign="top">
		            <strong>Developmental stage</strong><br>
                    <select name="devstage" size="10" style="width:200">
                    
                    <?php
						
						if(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));
	
							 while($row=pg_fetch_array($stmt)){
								print "<option value=\"".$row["DEV_STAGE_ID"]."\">";
								print $row["NAME"]."</option>\n";
								
							 }
						}
					 ?>
                  </select>
				</td>
				<td valign="top">&nbsp;
				    
				</td>
              </tr>
			  
			  
              <tr> 
                <td><hr size="1" color="#871F1F"></td>
                <td><hr size="1" color="#871F1F"></td>
				<td><hr size="1" color="#871F1F"></td>
              </tr>
			  
              <tr>
                <td>&nbsp;</td>
				<td>&nbsp;</td>
                <td align="right">
				    <input name="submit" type="image" src="pictures/button-submit.jpg" onClick="submit">
					&nbsp;&nbsp;
				    <br>
				</td>
              </tr>
            </table>
</form>

</center>


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