tengo los siguientes inputs, la idea es guardar toda esa info al tiempo, tengo entendido que hay hacer un arreglo para que funcione.
<form>
<input type="text" name="name_product[]">
<input type="text" name="detail_qnty[]">
<input type="text" name="detail_description[]">
<input type="text" name="name_product[]">
<input type="text" name="detail_qnty[]">
<input type="text" name="detail_description[]">
<form>
aqui se ingresa los datos y con el foreach se logro que guardara 2 nombres al tiempo, pero no se como agregarle el resto de campos.
if (isset($_POST['detail_description'])){
$detail_description=mysqli_real_escape_string($con,sanitize($_POST['detail_description']));
$detail_qnty= sanitize($_POST['detail_qnty']);
$name_product= sanitize($_POST['name_product']);
foreach ($_POST['name_product'] as $name_product) {
$sql="INSERT INTO `detail_addcourier_tmp` (`id`, `id_add`, `detail_weight`, `detail_length`, `detail_width`, `detail_height`, `detail_vol`, `detail_qnty`, `detail_description`, `name_product`, `detail_created`, `level`) VALUES (NULL, '".$numbers."', '$detail_weight', '$detail_length', '$detail_width', '$detail_height', '$detail_vol', '$detail_qnty', '$detail_description', '$name_product', NOW(), '".$user->username."');";
$insert=mysqli_query($con,$sql);
}
}
intente crear un arreglo para meter todos los campos algo asi
$datos = array($detail_qnty => 'detail_qnty', $detail_description => 'detail_description', $name_product => 'name_product');
foreach ($datos as $data){
aqui el insert
}
pero no me funciono, se guardan puros campos en blanco.
Como seria la mejor forma?
Gracias.