<div class="graph-visual tables-main">
<h2 class="inner-tittle">DIVISION</h2> Select your desired division below
	<div class="graph-form">
    		<div class="form-body">
    			<form method="post" name="divform" action="index.php?page=division"> 
                <?php 
                if($errmsg!=''){
                    echo '<div class="alert alert-danger">'.$errmsg.'</div>';
                }elseif($sucmsg!=''){
                    echo '<div class="alert alert-success">'.$sucmsg.'</div>';
                }
                
                
                   //GET DETAILS FROM DB

		    $q = "Select * from prob_application where id=$applicant_idgdef limit 1";
		    $qry=mysqli_query($con, $q);
		    $row=mysqli_fetch_assoc($qry);
		    extract($row);
		    
		    if(strlen($division)>0){ $div_available = "Yes"; $mydivision=$division; }else{ $div_available = "No"; }
                
                //onchange="jsFunction(this.value);"
                //onchange="this.form.submit()"
                
                ?>	
                	<label>Division </label>
                   	 <select id ="ddl" name="mydivision" class="form-control" style="height:auto" >
                   	 <?php if(isset($_POST["mydivision"]) || strlen($division)>0){ 
                   	 	extract($_POST); 
                   	 	//echo "<option selected>$mydivision</option>"; 
                   	 } 
                   	 ?>
			 
			  <option <?php if($mydivision == "BUILDING COST MANAGEMENT DIVISION"){ echo " selected"; } ?>>BUILDING COST MANAGEMENT DIVISION</option>
			  <option <?php if($mydivision == "BUILDING SERVICES COST MANAGEMENT DIVISION"){ echo " selected"; } ?>>BUILDING SERVICES COST MANAGEMENT DIVISION</option>
			  <option <?php if($mydivision == "PROJECT MANAGEMENT DIVISION"){ echo " selected"; } ?>>PROJECT MANAGEMENT DIVISION</option>
			  <option <?php if($mydivision == "CIVIL AND HEAVY ENGINEERING DIVISION"){ echo " selected"; } ?>>CIVIL AND HEAVY ENGINEERING DIVISION</option>
			</select>
			
			
                    <input name="updateDiv" type="submit" class="btn btn-default" value="Update Division"/> 
                </form> 
			
			
		
		<?php 
			//selected division
			if(isset($_POST["mydivision"]) || ($div_available =="Yes"))
			{
			   //get subjects
			   $q = "select * from examdivision2020 where division='$mydivision' AND exam='GDE'";
			   $r = mysqli_query($con, $q);
			   
			   echo "<br><B>SUBJECTS</B><br>";
			   $i = 1;
			   while($rows = mysqli_fetch_array($r))
			   {
			   	extract($rows);
			   	echo $i.". ".$subject." <br>";
			   	$i++;
			   }
			   
			   
			   //updated profile
			   $q2 = "update prob_application set division='$mydivision' where id=$applicant_idgdef limit 1";
			   $r2 = mysqli_query($con, $q2);
			   
			   if(!$r2){echo mysqli_error($con); }
			   
			}
			
		?>

    		</div>
    
    </div>

</div>
<div>
<a href='?page=disability'><button class='btn'>Back</button></a>
<?php
//check Division
 
if(strlen($division)>0)
{
  echo "<a href='?page=education'><button class='btn'>Next</button></a>";
} ?>
</div>


