Part 1 Creation of the form (HTML)

Prepare for two types of scenarios:

  1. When the form first open
  2. <tbody>
                        <tr>
                          <p>
    
                            <td><input type="checkbox" required="required" name="chk[]" checked="checked" />
    
                            </td>
                            <td>
    
                                <label>Start Year</label>   
                                <input type="hidden" id="edu" style="width:100px"  class="form-control" name="spprofile[eduID][]" >                       
                                    <input type="text" style="width:100px" required="required" class="form-control" name="spprofile[Startyear][]" placeholder="e.g. 2004">                        
                             </td>
                            <td>
                                <label>End Year</label>
                                <input type="text" style="width:100px" required="required" class="form-control" name="spprofile[Endyear][]"  placeholder="e.g. 2008">
                             </td>
                             <td>
                                <label>School Name</label>
                                <input type="text" style="width:200px" required="required" class="form-control" name="spprofile[School][]"  placeholder="e.g xyz university USA">
                             </td>
                             <td>
                                <label>Course Name/Description</label>
                                <input type="text" style="width:400px" required="required" class="form-control" name="spprofile[Course][]" placeholder="e.g information technology">
                             </td>
                             <td>
                                <label>Qualification Obtained</label>
    
                                <select class="form-control" name="spprofile[Qualification][]" required="required">
                                    <option value="PSLE" <?php if($Qualification[$i]=="PSLE") { echo "Selected"; } ?> >PSLE</option>
                                    <option value="Olevel" <?php if($Qualification[$i]=="Olevel") { echo "Selected"; } ?> >O level</option>
                                    <option value="Nlevel" <?php if($Qualification[$i]=="Nlevel") { echo "Selected"; } ?> >N level</option>
                                    <option value="Alevel" <?php if($Qualification[$i]=="Alevel") { echo "Selected"; } ?> >A level</option>
                                    <option value="Diploma" <?php if($Qualification[$i]=="Diploma") { echo "Selected"; } ?> >Diploma</option>
                                    <option value="Degree" <?php if($Qualification[$i]=="Degree") { echo "Selected"; } ?> >Degree</option>
                                    <option value="DegreeHon" <?php if($Qualification[$i]=="DegreeHon") { echo "Selected"; } ?> >Degree with Hons</option>
                                    <option value="Masters" <?php if($Qualification[$i]=="Masters") { echo "Selected"; } ?>  >Masters</option>
                                    <option value="Phd" <?php if($Qualification[$i]=="Phd") { echo "Selected"; } ?>  >Phd</option>
                                    <option value="TechnCert" <?php if($Qualification[$i]=="TechnCert") { echo "Selected"; } ?> >Techincal Certification</option>
                                    <option value="Others" <?php if($Qualification[$i]=="Others") { echo "Selected"; } ?> >Others</option>                                    
                                </select>
                             </td>                         
                                </p>
                            </tr>           
                        </tbody>
  3. When the form already have data from Database
  4.                 <?php 
                    if(!empty($Startyear)){
                        //foreach to be displayed
                        $i=0;
    
                        foreach($Startyear as $value){
    
                        //echo '<pre>', print_r($Startyear, true), '</pre>';
    
                        ?>
                        <tbody>
                        <tr>
                          <p>
                            <td><input type="checkbox" required="required" name="chk[]" checked="checked" /></td>                 
                            <td>
                                    <input type="hidden" id="edu" style="width:100px" class="form-control" name="spprofile[eduID][]" value="<?php
                                     if (isset($eduId[$i]))
                                          echo $eduId[$i];
                                    ?>">  
    
                                <label>Start Year</label>                           
                                    <input type="text" id="startyear[]" style="width:100px" required="required" class="form-control" name="spprofile[Startyear][]" value="<?php
                                     if (isset($value)) //{
                                          echo $value;
                                    // } elseif (isset($SPPROFILE['Start_year']['a'])) {
                                         // echo $SPPROFILE['Start_year']['a'];
                                    // }
                                    ?>" placeholder="e.g. 2004">                      
                             </td>
                            <td>
                                <label>End Year</label>
                                <input type="text" style="width:100px" required="required" class="form-control" name="spprofile[Endyear][]" value="<?php
                                     if (isset($Endyear[$i])) //{
                                          echo $Endyear[$i];
                                    // } elseif (isset($SPPROFILE['Start_year']['a'])) {
                                         // echo $SPPROFILE['Start_year']['a'];
                                    // }
                                    ?>" placeholder="e.g. 2008">
                             </td>
                             <td>
                                <label>School Name</label>
                                <input type="text" style="width:200px" required="required" class="form-control" name="spprofile[School][]"  value="<?php
                                     if (isset($School[$i])) //{
                                          echo $School[$i];
                                    // } elseif (isset($SPPROFILE['Start_year']['a'])) {
                                         // echo $SPPROFILE['Start_year']['a'];
                                    // }
                                    ?>" placeholder="e.g xyz university USA">
                             </td>
                             <td>
                                <label>Course Name/Description</label>
                                <input type="text" style="width:400px" required="required" class="form-control" name="spprofile[Course][]" value="<?php
                                     if (isset($Course[$i])) //{
                                          echo $Course[$i];
                                    // } elseif (isset($SPPROFILE['Start_year']['a'])) {
                                         // echo $SPPROFILE['Start_year']['a'];
                                    // }
                                    ?>" placeholder="e.g information technology">
                             </td>
                             <td>
                                <label>Qualification Obtained</label>
                                <select class="form-control" name="spprofile[Qualification][]" required="required">
                                    <option value="PSLE" <?php if($Qualification[$i]=="PSLE") { echo "Selected"; } ?> >PSLE</option>
                                    <option value="Olevel" <?php if($Qualification[$i]=="Olevel") { echo "Selected"; } ?> >O level</option>
                                    <option value="Nlevel" <?php if($Qualification[$i]=="Nlevel") { echo "Selected"; } ?> >N level</option>
                                    <option value="Alevel" <?php if($Qualification[$i]=="Alevel") { echo "Selected"; } ?> >A level</option>
                                    <option value="Diploma" <?php if($Qualification[$i]=="Diploma") { echo "Selected"; } ?> >Diploma</option>
                                    <option value="Degree" <?php if($Qualification[$i]=="Degree") { echo "Selected"; } ?> >Degree</option>
                                    <option value="DegreeHon" <?php if($Qualification[$i]=="DegreeHon") { echo "Selected"; } ?> >Degree with Hons</option>
                                    <option value="Masters" <?php if($Qualification[$i]=="Masters") { echo "Selected"; } ?>  >Masters</option>
                                    <option value="Phd" <?php if($Qualification[$i]=="Phd") { echo "Selected"; } ?>  >Phd</option>
                                    <option value="TechnCert" <?php if($Qualification[$i]=="TechnCert") { echo "Selected"; } ?> >Techincal Certification</option>
                                    <option value="Others" <?php if($Qualification[$i]=="Others") { echo "Selected"; } ?> >Others</option>                                    
                                </select>
                             </td>                         
                                </p>
                            </tr>           
                        </tbody>
    
                        <?php
                        $i++;
                        }
    } ?>