<?php
$errmsg='';
$sucmsg='';
if(isset($_POST['addInstituttion'])){
    extract($_POST);
    $errmsg='';
    $sucmsg='';
    
		//update record
	$qry2=mysqli_query($con, "insert into pci_body values('', '$applicant_idpci', '$institution', '$currentGrade', '$regRoute', '$regYear')");
	if($qry2){
		$sucmsg='Successful!';
	}else{
		$errmsg='Not Successful!';
		//echo mysqli_error($con);
	}
	
    
}



?>

<div class="graph-visual tables-main">
<h2 class="inner-tittle">MEMBERSHIP OF ANY OTHER PROFESSIONAL INSTITUTION(S): (IF ANY)
</h2>
	<div class="graph-form">
    		<div class="form-body">
				 <?php
				//GET DETAILS FROM DB
	
				$q = "Select * from pci_body where applicant_id='$applicant_idpci'";
				$qry=mysqli_query($con, $q);
				if($qry){
					
					if(mysqli_num_rows($qry) >0){
						$yyy = 1;
						echo '<div>';
						echo "<table width='100%' border='1' cellspacing='2'>";
						echo "<tr><td><b>SN</b></td> <td><b>Institution </b></td>  <td><b>Current Grade </b></td>  <td><b>Membership Route </b></td>  <td><b>Date Elected</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>$currentGrade </td> <td>$regRoute </td> <td>$regYear</td> </tr>";
							echo "<tr><td>$yyy</td> <td>$institution </td> <td>$currentGrade </td> <td>$regRoute </td> <td>$regYear </td><td> <form method='post' action='index.php?page=bodyeditor'><input type='hidden' value='$id' name='editID'><input type='submit' value='Edit'></form> </td> </tr>";
							$yyy++;
						}
						
						echo "</tables></div>";
						
					}else{  
					// $errmsg='No record found!'; 
					
					}
							
				}else{
					//$errmsg='No record found!';
				}
				
				?>
				
    			<form method="post" name="bodyform" action="index.php?page=body"> 
               
				<?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>Current Grade</label> 
                        <input type="text" class="form-control" name="currentGrade" required="" /> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>How Membership was achieved</label> 
                        <input type="text" class="form-control" name="regRoute" placeholder="e.g Examination" required="" /> 
                    </div> 
					
					<div class="form-group"> 
                        <label>Year Registered/Elected</label> 
                        <input type="text" class="form-control" name="regYear" placeholder="e.g 2014" required="" />  
                    </div> 
                    
                    <div class="form-group"> 
                    <input name="addInstituttion" type="submit" class="btn btn-default" value="Add Record"/> 
                </form>
    		</div>
    
    </div>

</div>

   
<?php

 echo "<div>";
 echo "  <a href='?page=education'><button class='btn'>Back</button></a>"; 
 echo "  <a href='?page=tpc'><button class='btn'>Next</button></a>"; 
 echo "</div>";

?>