Im trying to insert multiple data that has only been selected checkbox. But Unfortunately, It also inserted the the unselected checkbox and also getting duplicate data.
Here's the UI for selecting data.
Here's my code:
if(isset($check)){
$client = $_POST['client'];
$project = $_POST['project'];
$kit_no = $_POST['kit_no']; //array
$kit_desc = $_POST['kit_desc']; //array
for($i=0;$i<sizeof($check);$i++){
for($i=0;$i<sizeof($kit_no);$i++){
for($i=0;$i<sizeof($kit_desc);$i++){
$query=mysqli_query($con,"INSERT INTO tbltrainsets_kit(id, client, project, kit_no, kit_desc)VALUES(
'',
'".$client."',
'".$project."',
'".$kit_no[$i]."',
'".$kit_desc[$i]."'
)")or die(mysqli_error($con));
}
}
}
}
The output that I produce is like this: (Please see the actual pix below):
The unselected data ('NA') was inserted into the database. It should only be the item 'DTR4000037253' inserting into the database.
Thank you in advace. Please respect my questions. I'm still studying do please do not bash. :|