Foros del Web » Programando para Internet » PHP »

Insertar Varios campos en mi base de datos

Estas en el tema de Insertar Varios campos en mi base de datos en el foro de PHP en Foros del Web. Buenas tardes tengo un formulario dinámico y quiero hacer los insert a la base de datos me pueden indicar como hacerlo gracias <!doctype html> <html> ...
  #1 (permalink)  
Antiguo 16/06/2015, 11:43
Avatar de lmarin2008  
Fecha de Ingreso: junio-2015
Ubicación: Medellin Colombia
Mensajes: 7
Antigüedad: 8 años, 10 meses
Puntos: 0
Insertar Varios campos en mi base de datos

Buenas tardes tengo un formulario dinámico y quiero hacer los insert a la base de datos me pueden indicar como hacerlo gracias
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<script src="../Insertar_varios_registros/ADDCAMPOS/jquery-1.9.1.min.js"></script>
<style type="text/css">
input[type="text"]{
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
border-radius: 4px 4px 4px 4px;
color: #555555;
display: inline-block;
font-size: 14px;
height: 20px;
line-height: 20px;
margin-bottom: 10px;
padding: 4px 6px;
vertical-align: middle;
}
input[type="text"]:focus {
border-color: rgba(82, 168, 236, 0.8);
outline: 0 none;
-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(82,168,236,.6);
-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(82,168,236,.6);
box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(82,168,236,.6);
}
a {
text-decoration: none;
}


.btn {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
border-image: none;
border-radius: 4px 4px 4px 4px;
border-style: solid;
border-width: 1px;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 2px rgba(0, 0, 0, 0.05);
cursor: pointer;
display: inline-block;
font-size: 14px;
line-height: 20px;
margin-bottom: 0;
padding: 4px 12px;
text-align: center;
vertical-align: middle;
}
.btn-info {
background-color: #49AFCD;
background-image: linear-gradient(to bottom, #5BC0DE, #2F96B4);
background-repeat: repeat-x;
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
color: #FFFFFF;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
}
.btn:hover{
color:#333;
text-decoration:none;
background-position:0 -15px;
-webkit-transition:background-position .1s linear;
-moz-transition:background-position .1s linear;
-o-transition:background-position .1s linear;
transition:background-position .1s linear;
}
.btn-info:hover{
color:#fff;
background-color:#2f96b4;
}
#contenedor {
margin-top: 15px;
}
#wrapper {
width: 380px;
margin: 50px auto 0;
}
.added {
float: left;
margin-right: 10px;
}
.eliminar {
margin: 5px;
}
</style>
<script type="text/javascript">
$(document).ready(function() {

var MaxInputs = 8; //maximum input boxes allowed
var contenedor = $("#contenedor"); //Input boxes wrapper ID
var AddButton = $("#agregarCampo"); //Add button ID

//var x = contenedor.length; //initlal text box count
var x = $("#contenedor div").length + 1;
var FieldCount = x-1; //to keep track of text box added

$(AddButton).click(function (e) //on add input button click
{
if(x <= MaxInputs) //max input box allowed
{
FieldCount++; //text box added increment
//add input box
$(contenedor).append('<div class="added"><table width="100%" border="0" cellspacing="0"><tr><td><input type="text" name="luber[]" id="luber_'+ FieldCount +'" placeholder="luber '+ FieldCount +'"/></td><td><input type="text" name="producto[]" id="producto_'+ FieldCount +'" placeholder="producto '+ FieldCount +'"/></td><td><input type="text" name="mitexto[]" id="campo_'+ FieldCount +'" placeholder="Texto '+ FieldCount +'"/></td><td><a href="#" class="eliminar">&times;</a></td></tr></table></div>');
x++; //text box increment
}
return false;
});

$("body").on("click",".eliminar", function(e){ //user click on remove text
if( x > 1 ) {
$(this).parent('div').remove(); //remove text box
x--; //decrement textbox
}
return false;
});

});
</script>
</head>
<body>

<div id="wrapper">
<a id="agregarCampo" class="btn btn-info" href="#">Agregar Campo</a>
<div id="contenedor">

<div class="added">
<form action="guardar.php" method="post"><table width="100%" border="0" cellspacing="0">
<tr>
<td><input type="text" name="nombre[]" id="nombre_1" placeholder="nombre 1"/></td>
<td><input type="text" name="valor[]" id="valor_1" placeholder="valor 1"/></td>
<td><input type="text" name="total[]" id="total_1" placeholder="total 1"/></td>
<td><a href="#" class="eliminar">&times;</a></td>
</tr>
</table>


</div>
</div><input name="Enviar" type="submit" class="btn-info" value="Guardar">
</form>
</div>
</body>


</html>
  #2 (permalink)  
Antiguo 16/06/2015, 12:14
 
Fecha de Ingreso: mayo-2013
Mensajes: 191
Antigüedad: 10 años, 11 meses
Puntos: 10
Respuesta: Insertar Varios campos en mi base de datos

Del lado cliente con mandar el form era suficiente para que se entienda:

Código HTML:
Ver original
  1. <form action="guardar.php" method="post"><table width="100%" border="0" cellspacing="0">
  2. <tr>
  3. <td><input type="text" name="nombre[]" id="nombre_1" placeholder="nombre 1"/></td>
  4. <td><input type="text" name="valor[]" id="valor_1" placeholder="valor 1"/></td>
  5. <td><input type="text" name="total[]" id="total_1" placeholder="total 1"/></td>
  6. <td><a href="#" class="eliminar">&times;</a></td>
  7. </tr>
  8.  
  9.  
  10. </div>
  11. </div><input name="Enviar" type="submit" class="btn-info" value="Guardar">
  12. </form>

Ahora falta saber lo que tienes en el guardar.php para poder sugerirte algo
  #3 (permalink)  
Antiguo 16/06/2015, 14:33
Avatar de lmarin2008  
Fecha de Ingreso: junio-2015
Ubicación: Medellin Colombia
Mensajes: 7
Antigüedad: 8 años, 10 meses
Puntos: 0
Respuesta: Insertar Varios campos en mi base de datos

Cita:
Iniciado por matake Ver Mensaje
Del lado cliente con mandar el form era suficiente para que se entienda:

Código HTML:
Ver original
  1. <form action="guardar.php" method="post"><table width="100%" border="0" cellspacing="0">
  2. <tr>
  3. <td><input type="text" name="nombre[]" id="nombre_1" placeholder="nombre 1"/></td>
  4. <td><input type="text" name="valor[]" id="valor_1" placeholder="valor 1"/></td>
  5. <td><input type="text" name="total[]" id="total_1" placeholder="total 1"/></td>
  6. <td><a href="#" class="eliminar">&times;</a></td>
  7. </tr>
  8.  
  9.  
  10. </div>
  11. </div><input name="Enviar" type="submit" class="btn-info" value="Guardar">
  12. </form>

Ahora falta saber lo que tienes en el guardar.php para poder sugerirte algo
  #4 (permalink)  
Antiguo 16/06/2015, 14:33
Avatar de lmarin2008  
Fecha de Ingreso: junio-2015
Ubicación: Medellin Colombia
Mensajes: 7
Antigüedad: 8 años, 10 meses
Puntos: 0
Respuesta: Insertar Varios campos en mi base de datos

Hola mira es que me gustaria que me sugirieran como debo hacerlo ya que he probado de varias formas y no me da

Etiquetas: campos, formulario, html, registro
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:57.