-2
I have a script that makes a registration
works like this: in a dynamic table, each row has an input that is checkbox type and it loads an id and another input is number type and loads any value
Hence it occurs that $_POST gets arrays with distinct numbers of indices. for example, if in this table I mark only the last checkbox and put a value in the last input number, the checkbox array will have a true value for its Dice 0, at the same time that the value I put in the input number will be in another Dice, which means the loop will not catch the correct number value..
foreach($fator as $k => $v){
try{
$sql = "INSERT INTO " . EMP_MODALIDADES . " (eid,mid,fator) VALUES (:eid,:mid,:fator)";
$insert = $link->prepare($sql);
$insert->bindValue(':eid',$eid);
$insert->bindValue(':mid',$v);
$insert->bindValue(':fator',$fator[$k]);
$insert->execute();
}
catch(PDOException $erro){
die('INSERT error: '.$erro->getMessage());
}