Hi, I have a code that works to insert multiple records but only one array, I plan to add more inouts with different arrays but I can not find how to modify the part of the arrays. I imagine that in the case of the sql it would be something like this:
$insertStmt = $db->prepare("INSERT INTO productos (producto, id, etc) VALUES (:field, :id, etc)");
Correct me if I'm wrong
if(isset($_POST['btn-add']))
{
$fields= (is_array($_POST['fields'])) ? $_POST['fields'] : array();
$insertStmt = $db->prepare("INSERT INTO productos (producto) VALUES (:field)");
foreach ($fields as $field) {
$insertStmt->execute(array('field' => $field));
}
header("Location: productos.php");
}
?>
So I have my input:
$(container).append('<input type=text required="required" name ="fields[]" class="input" id=tb' + iCnt + ' ' +
'placeholder="Producto ' + iCnt + '" />');