Hi all,
I have a form which is created by the results of a SQL query from table1. Depending on the result of the query, say 20 rows, then the form will have 20 rows (20 Questions and 20 checkbox).
Form part:
<textarea name="audititem[]"><?php echo $row_InspectItems['AuditItem']; ?></textarea>
<input type="hidden" name="audititemid[]" id="hiddenField" value="<?php echo $row_InspectItems['RecordID']; ?>">
<input name="check[]" type="checkbox" class="checkbox" value="<?php echo $row_InspectItems['RecordID']; ?>">
Process Part:
$Questions[] = $_POST['audititem'];
$Check[] = $_POST['check'];
foreach($_POST['audititem'] as $key => $question) {
$check = $_POST['check'][$key];
$query = mysql_query("INSERT INTO table2 (AuditItem, AuditCheck) VALUES ('{$question}','{$check }')");
}
The problem I have is when the data is inserted to table2 the matching question and checkbox value do not get written to the correct feilds.
Example:
If (form)
question1 checkbox is selected
question2 checkbox is selected
question15 checkbox is selected
the data gets written as
Feild Question1 "question1" Feild Question1 checkbox 1
Feild Question2 "question2" Feild Question2 checkbox 2
Feild Question15 "question15" Feild Question3 checkbox 3
I think my question is how do I keep the question matched to the checkbox result.