Hola habia tenido una duda similar a esta pero me salio otra asi que si me pudieran ayudar estaria muy agradecido con ustedes
tengo este form
y se puede agregar mas inputs pero al momento de quererlo meter a la base de datos solo puedo meter un formgroup no completamente todos los inputs
<html>
<head>
<title>Pedir material | Departamento de almacen</title>
</head>
<body>
<div align="center">
<div class="content-wrapper">
<div class="content">
<div class="row">
<div class="col-md-6">
<div class="box box-primary">
<div class="form-group">
<form name="add_name" id="add_name">
<div class="box-body">
<div class="row" id="dynamic_field">
<div class="col-md-6">
<input type="text" name="name[]" placeholder="Material" class="form-control name_list" autofocus="" />
</div>
<div class="col-md-2">
<input class="form-control" type="number" placeholder="Cantidad" name="name[]" />
<input type="text" value="<?php echo $qls->user_info['username'] ?>" name="name[]" hidden>
<input type="text" value="<?php echo $qls->user_info['departamento'] ?>" name="name[]" hidden>
</div>
<div class="col-md-2">
<input class="form-control" type="text" name="name[]" placeholder="Mensaje">
</div>
<div class="col-md-2">
<button type="button" name="add" id="add" class="btn btn-success"><b>+</b></button>
</div>
</div>
<br>
<input type="button" name="submit" id="submit" class="btn btn-info" value="Submit" />
</div>
</form>
</div>
</div>
</div>
<div class="col-md-3">
<div class="box box-primary">
<div class="box-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
</div>
<div class="col-md-3">
<div class="box box-primary">
<div class="box-body">
<div class="callout callout-warning">
<h4>Mensaje</h4>
<p>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="dist/js/app.js"></script>
</body>
</html>
<script>
$(document).ready(function(){
var i=1;
$('#add').click(function(){
i++;
$('#dynamic_field').append('<div id="row'+i+'"><div class="col-md-6"><input type="text" name="name[]" placeholder="Material" class="form-control name_list" /></div><div class="col-md-2"><input class="form-control" type="number" placeholder="Cantidad"/><input type="text" value="<?php echo $qls->user_info['username'] ?>" name="usuario" hidden><input type="text" value="<?php echo $qls->user_info['departamento'] ?>" name="departamento" hidden></div><div class="col-md-2"><input type="text" name="mensaje" class="form-control" placeholder="Mensaje"></div><div class="col-md-2"><button type="button" name="remove" id="'+i+'" class="btn btn-danger btn_remove">X</button></div>');
});
$(document).on('click', '.btn_remove', function(){
var button_id = $(this).attr("id");
$('#row'+button_id+'').remove();
});
$('#submit').click(function(){
$.ajax({
url:"name.php",
method:"POST",
data:$('#add_name').serialize(),
success:function(data)
{
alert(data);
$('#add_name')[0].reset();
}
});
});
});
</script>
<script type="text/javascript">
$(document).ready(function() {
setInterval(function () {
$('#message').load('message.php')
}, 1000);
});
$(document).ready(function() {
setInterval(function () {
$('#nmessage').load('nmessage.php')
}, 1000);
});
$(document).ready(function() {
setInterval(function () {
$('#mtotales').load('mtotales.php')
}, 1000);
});
</script>
}
</div>
</body>
</html>
<?php
$connect = mysqli_connect("localhost", "root", "rootroot", "sasal");
$number = count($_POST["name"]);
if($number > 0)
{
for($i=0; $i<$number; $i++)
{
if(trim($_POST["name"][$i] != ''))
{
$sql = "INSERT INTO pedidos(material,cantidad,estado,mensaje,departamento,usuario,fecha,hora) VALUES('".mysqli_real_escape_string($connect, $_POST["name"][0]). "','" . mysqli_real_escape_string($connect, $_POST["name"][1])."','" . 0 . "','" . mysqli_real_escape_string($connect, $_POST["name"][4]). "','" . mysqli_real_escape_string($connect, $_POST["name"][3]). "','" . mysqli_real_escape_string($connect, $_POST["name"][2]). "','" .date('d/m/Y') . "','". date('H:i a') ."')";
print("Debug qry $i: $sql");
mysqli_query($conn, $sql);
}
}
echo "Data Inserted Successfully";
}
?>