Click here to Skip to main content
14,423,188 members
Rate this:
Please Sign up or sign in to vote.
See more:
Dear Exports,

I made a job application form which is use for apply online at particular vacancy and stores applicant data

it include qualification portion in which user can feed multiple qualification using add more button

and i used 4 tables behind this scenario.

so my problems are:
1) How can store data in 4 tables using prepare statement.

2)How to add multiple qualifications in database when user want to add

kinldy help me for this


Thanks in advance

What I have tried:

<div style="font-size: 18px; margin-top: 50px; font-family: Helvetica,Arial,sans-serif; font-weight: bolder;">
        <label>Work History</label><span style="font-size: 12px;">(Start With Most Recent)</span>
        </div>

<table class="table table-bordered" id="dynamicTable1">
      <tr>
          <th style="background-color: grey; width:135px;border:1px solid black; margin-right: 1px; ">Position Held</th>
          <th style="background-color: grey; width:220px;border:1px solid black; margin-right: 1px;">Organization Name</th>
          <th style="background-color: grey; width:130px;border:1px solid black; margin-right: 1px;">From Date</th>
          <th style="background-color: grey; width:130px;border:1px solid black; margin-right: 1px;">To Date</th>
          <th style="background-color: grey; width:70px;border:1px solid black; margin-right: 2px;">Service in Year</th>
          <th style="background-color: grey; width:90px;border:1px solid black; margin-right: 1px;">Last Drawn Gross Salary</th>
          <th style="background-color: grey; width:130px;border:1px solid black; margin-right: 1px;">Reason For Leaving</th>
      </tr>
      <tr>
          <td  style=" width:135px;margin-right: 2px;margin-top: 1px;">
          <input type="text" name="positionheld[]" style = "width : 135px;  font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 28px; padding-left: 3px;"></td>
<td style=" width:219px;margin-right: 1px;margin-top: 1px;">
<input type="text" name="orgname[]" style = "width: 220px;font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 28px;padding-left: 3px;">    
</td>
<td style=" width:130px;margin-right: 1px;margin-top: 1px;">
<input type="date" name="fromdate[]" style = "width: 125px; font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 28px;">    
</td>
<td style=" width:130px;margin-right: 1px;margin-top: 1px;">
<input type="date" name="todate[]" style = "width: 125px; font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 28px;">    
</td>
<td style=" width:70px;margin-right: 2px;margin-top: 1px;">
<input type="number" name="serviceyear[]" pattern="[-+]?[0-9]*[.,]?[0-9]+" style = "width: 52px;font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 20px;">    
</td>
<td style=" width:90px;margin-right: 1px;margin-top: 1px;">
<input type="text" name="lastgrosssal[]" pattern="[-+]?[0-9]*[.,]?[0-9]+" style = "width: 90px;font-size : 13px ; border-radius : 5px; padding-left: 3px; border: 1px solid gray; height: 28px;">    
</td>
<td style=" width:130px;margin-right: 1px;margin-top: 1px;">
<input type="text" name="reason[]" style = "width: 130px;font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 28px; padding-left: 3px;">    
</td>
<td style="width: 85px;margin-right: 1px;margin-top: 1px; border:none;"><button type="button" name="add1" id="add1" class="btn btn-success">Add More</button></td>

      </tr>
  </table> 

Jquery code
<script type="text/javascript">
     var i = 0;
       
    $("#add1").click(function(){
   
        ++i;
   
        $("#dynamicTable1").append('<tr><td  style=" width:135px;"><input type="text" name="positionheld[]" style = "width : 135px;  font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 28px;"></td><td style=" width:220px;"><input type="text" name="orgname[]" style = "width: 220px;font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 28px;"></td><td style=" width:130px;"><input type="date" name="fromdate[]" style = "width: 125px; font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 28px;"></td><td style=" width:130px;"><input type="date" name="todate[]" style = "width: 125px; font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 28px;"></td><td style=" width:70px;"><input type="number" name="serviceyear[]" pattern="[-+]?[0-9]*[.,]?[0-9]+" style = "width: 52px;font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 20px;"></td><td style=" width:90px;"><input type="number" name="lastgrosssal[]" pattern="[-+]?[0-9]*[.,]?[0-9]+" style = "width: 74px;font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 20px;"></td><td style=" width:130px;"><input type="text" name="reason[]" style = "width: 130px;font-size : 13px ; border-radius : 5px; border: 1px solid gray; height: 28px;"></td><td style="width:85px;"><button type="button" class="btn btn-danger remove-tr1">Remove</button></td></tr>');
    });
   
    $(document).on('click', '.remove-tr1', function(){  
         $(this).parents('tr').remove();
    }); 


php code need to improve

<?php 

include 'db.php';
$id = $_POST['id'];
$name = $_POST['name'];
$fathername= $_POST['fathername'];
$cnic= $_POST['cnic'];
$gender=$_POST['gender'];
$maritalstatus= $_POST['maritalstatus'];
$religion=$_POST['religion'];
$dob=$_POST['dob'];
$paddress=$_POST['paddress'];
$province=$_POST['province'];
$city=$_POST['city'];
$phone=$_POST['phone'];
$mob=$_POST['mob'];
$email=$_POST['email'];
$expected_salary = $_POST['expectslry'];
$job_id = "";
$status = "";
$degree1 = $_POST['degree1'];
$institute1 = $_POST['institute1'];
$institute1city = $_POST['institute1city'];
$discipline = $_POST['discipline'];
$year1 = $_POST['year1'];
$obtainmarks = $_POST['obtainmarks'];
$totalmarks = $_POST['totalmarks'];
$CGPA = $_POST['CGPA'];
$certificatename = $_POST['certificatename'];
$certificateins = $_POST['certificateins'];
$completionyear = $_POST['completionyear'];
$certificatespec = $_POST['certificatespec']; 




if(isset($_POST['submit'])){

$sql = "INSERT into job_application (`application_id`, `name`, `father_name`, `cnic`, `marital_status`, `gender`, `dob`, `religion`, `address`, `province`, `city`, `phone`, `mobile`, `email`, `expected_salary`) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
        INSERT INTO `job_application_qualification`(`application_id`, `degree_name`, `institute_name`, `institute_city`, `discipline`, `pass_year`, `obtain_marks`, `total_marks`, `grade`, `cert_name`, `cert_inst_name`, `cert_pass_year`, `cert_discipline`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?); " ;
$stmt = mysqli_stmt_init($con);
if(!mysqli_stmt_prepare($stmt,$sql)){

	echo ("Database Error".mysqli_connect_error());
	exit();
}
else{
mysqli_stmt_bind_param($stmt,"sssisssssiisssiissssisssssis",$id,$name,$fathername,$cnic,$maritalstatus,$gender,$dob,$religion,$paddress,$province,$city,$phone,$mob,$email,$expected_salary,last_insert_id(),$degree1,$institute1,$institute1city,$discipline,$year1,$obtainmarks,$totalmarks,$CGPA,$certificatename,$certificateins,$completionyear,$certificatespec);


mysqli_stmt_execute($stmt);
echo "Data inserted Successfully";

}

}

?>
Posted
Updated 13-Jan-20 20:58pm
v3
Comments
Richard MacCutchan 14-Jan-20 5:52am
   
What exactly is the problem?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100