<?php
$errmsg='';
$sucmsg='';
if(isset($_POST['addInstituttion'])){
    extract($_POST);
    $errmsg='';
    $sucmsg='';
    
	//print_r($_POST);
		
	//insert record
	$qry2=mysqli_query($con, "insert into pci_education values('', '$applicant_idpci', '$institution', '$country', '$degree', '$course', '$dateCompleted')");
	if($qry2){
		$sucmsg='Successful!';
	}else{
		//echo mysqli_error($con);
		$errmsg='Not Successful!';
		
	}
	
    
}



?>

<div class="graph-visual tables-main">
<h2 class="inner-tittle">EDUCATION (TERTIARY)</h2>
	 Please list all academic qualification(s). <BR>For each qualification, please indicate if you studied for the full duration of the course or whether you gained advanced entry to the course. If you gained advanced entry, which year of the course did you enter at (e.g. year 3 of a possible 5)?
	<div class="graph-form">
    		<div class="form-body">
		
    		<?php
				//GET DETAILS FROM DB
	
				$q = "Select * from pci_education where applicant_id='$applicant_idpci'";
				$qry=mysqli_query($con, $q);
				if($qry){
					
					if(mysqli_num_rows($qry) >0){
						$myallow = 1;  //allow next button to display
						$yyy = 1;
						echo "<table width='100%' border='0'>";
						echo "<tr><td colspan='5'>";
						echo "<table width='100%' border='1'>";
						echo "<tr><td><b>SN</b></td> <td><b>Institution </b></td>  <td><b>Country </b></td>  <td><b>Degree Obtained </b></td>  <td><b>Date Completed</b></td> <td><b>Action</b></td> </tr> ";
						
						while($row=mysqli_fetch_assoc($qry))
						{
							extract($row);
							echo "<tr><td>$yyy</td> <td>$institution </td> <td>$country </td> <td>".strtoupper($degree)." in $course </td> <td>$dateCompleted</td> <td> <form method='post' action='index.php?page=educationeditor'><input type='hidden' value='$id' name='editID'><input type='submit' value='Edit'></form> </td></tr>";
							$yyy++;
						}
						
						echo "</tables></td></tr>";
						echo "</tables> ";
						
					}else{ $errmsg='No record found!'; $myallow = 0; }
							
				}else{
					$errmsg='No record found!';
					$myallow = 0;
				}
				
				?>
			
			
			
			
    			<form method="post" name="educationform" action="index.php?page=education"> 
                <?php 
                if($errmsg!=''){
                    echo '<div class="alert alert-danger">'.$errmsg.'</div>';
                }elseif($sucmsg!=''){
                    echo '<div class="alert alert-success">'.$sucmsg.'</div>';
                }
                
                ?>
                    <div class="form-group"> 
                        <label>Institution</label> 
                        <input type="text" class="form-control" name="institution" placeholder="name of institution" required="" />  
                    </div> 
                    
					<div class="form-group"> 
                        <label>Country</label> 
                        <input type="text" class="form-control" name="country" required="" /> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>Degree Obtained</label> 
                        <input type="text" class="form-control" name="degree" placeholder="e.g B.TECH, BSc, HND" required="" /> 
                    </div> 
					
					<div class="form-group"> 
                        <label>Course</label> 
                        <input type="text" class="form-control" name="course" value="QUANTITY SURVEYING" required="" /> 
                    </div> 
					
					<div class="form-group"> 
                        <label>Date Completed</label> 
                        <input type="date" class="form-control" name="dateCompleted" required="" style="height:auto"/>  
                    </div> 
                   
                    
                    <input name="addInstituttion" type="submit" class="btn btn-default" value="Add Record"/> 
                    
                </form> 
                
    		</div>
    		
    
    </div>
    
    
  </div>  
   
<?php

 echo "<div>";
 echo "  <a href='?page=olevel'><button class='btn'>Back</button></a>"; 
 
if($myallow != 0){ echo "  <a href='?page=body'><button class='btn'>Next</button></a>"; }
 echo "</div>";

?>