Hi,
Am stumped on this one...
have a form that gathers user's previous work history. The fields are :
Company name,
Title,
Location,
start date,
end date
Job duties
The problem is these fields appear three times on the page, allowing the users to fill in up to three previous jobs.
The idea was to insert the form data into the table, using up to three rows, but of course this would vary depending on how many previous jobs they entered.
the various form fields on the HTML page are named as follows:
<input type="text" size="52" name="comp1" class="textbox">
<input type="text" size="52" name="title1" class="textbox">
<select size="1" name="smonth1" class="textbox">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
etc...
the second iteration of this form is similar but appends "2" to the end of each form field name:
<input type="text" size="52" name="comp2" class="textbox">
<input type="text" size="52" name="title2" class="textbox">
<select size="1" name="smonth2" class="textbox">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
etc...
And the third iteration of course appends a "3" in the same manner...
Here is the code for the page that processes the for data:
$job_history_array = array();
for($z=0;$z<3;$z++) { //the counter stops at 3 because there are 3 iterations of the form fields
$jhnum = count($job_history_array);
$job_history_array[$jhnum]["company_name"] = $POST["comp$z"];
$job_history_array[$jhnum]["position_title"] = $POST["title$z"];
$job_history_array[$jhnum]["startdate"] = ($POST['syear$z']."-".$POST['smonth$z']."-".01);
$job_history_array[$jhnum]["enddate"] = ($POST['eyear$z']."-".$POST['emonth$z']."-".01);
$job_history_array[$jhnum]["location"] = $POST["joblocation$z"];
$job_history_array[$jhnum]["duties"] = $POST["desc$z"];
}
for($i=0;$i<count($jhnum);$i++) {
$querystring = "INSERT INTO new_resume_job_history(new_history_id,resume_id,company_name,position_title,startdate,enddate,location,duties) VALUES ('NULL','$res_id','$POST['comp$i']','$POST['title$i']','$POST['syear$i']."-".$POST['smonth$i']."-".01','$POST['eyear$i']."-".$POST['emonth$i']."-".01','$POST['joblocation$i']','$POST['desc$i']')";
$result = mysql_query($querystring) or die ('Problem: ' . mysql_error());
}
I have tried this several ways and it either throws an error or doesn't grab the data from the form at all.
Any help would be great,
Thanks.