Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/04/2015, 16:08
facundojr07
 
Fecha de Ingreso: enero-2013
Mensajes: 64
Antigüedad: 11 años, 3 meses
Puntos: 0
Insertar varias filas en una Tabla mediante Formulario

Buenas,

Estoy queriendo lograr que mediante un formulario inserte varias filas en una tabla. Pero el problema que estoy teniendo es que solo me agrega la ultima fila, osea de tres filas sólo me agrega una que es la última.

El código que utilizo para insertar es:

Código PHP:
    $sql "INSERT INTO apuestas (ID_Partido, fecha_hora, numero_fecha, numero_partido, LOCAL, Visitante, ID_usuario, usuario, aposto)";
   
$sql.= "VALUES ('".$ID_Partido."','".$fecha_hora."', '".$numero_fecha."', '".$numero_partido."', '".$Local."', '".$Visitante."', '".$ID_usuario."', '".$usuario."', '".$aposto."')";

    
mysql_query($sql$conexion); 
Y el formulario:
Código PHP:
 <form method="post" id="frEmpresa" action="inicio.php">
<?php while ($rsEmp mysql_fetch_assoc($queEmp)) { ?>
  <tr>
    <td>
    <input type="text" id="ID_Partido" name="ID_Partido"/></td>
    <td>
    <input name="fecha_hora" type="text" id="fecha_hora" value="<?php echo $rsEmp['fecha_hora']; ?>" /></td>
    <td>
    <input type="text" id="numero_fecha" name="numero_fecha" value="<?php echo $rsEmp['numero_fecha']; ?>"/></td>
    <td>
    <input type="text" id="numero_partido" name="numero_partido" value="<?php echo $rsEmp['numero_partido']; ?>" /></td>
    <td>
    <input type="text" id="Local" name="Local" value="<?php echo $rsEmp['Local']; ?>"/></td>
    <td>
    <input type="text" id="Visitante" name="Visitante" value="<?php echo $rsEmp['Visitante']; ?>"/></td>
    <td>
    <input type="text" id="ID_usuario" name="ID_usuario" value="<?php echo $_SESSION['usuario_id'?>"/></td>
    <td>
    <input type="text" id="usuario" name="usuario" value="<?php echo $_SESSION['usuario_login'?>"/></td>
    <td>
    <input type="text" id="aposto" name="aposto" /></td>
    </tr>
     <?php ?>
           <tr>
    <td><label for="bts">&nbsp;</label>
    <button type="submit">Guardar</button>
    <button type="reset">Limpiar</button>
</form>
  </tr>
Por ejemplo si completo el formulario con:
1 texto1a texto1b texto1c
2 texto2a texto2b texto2c
3 texto3a texto3b texto3c

Solamente en la base de datos me aparecerá:
3 texto3a texto3b texto3c