Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/02/2014, 16:19
Avatar de Briss
Briss
 
Fecha de Ingreso: junio-2011
Mensajes: 1.293
Antigüedad: 12 años, 10 meses
Puntos: 12
Mi insert multiple no funciona solo inserta un registro

Hola a todos estoy tratando de hacer un insert multiple con este codigo al momento solo me monda un registro aunque tenga dos o mas... espero me puedan ayudar ya que no encuentro mi error


Código PHP:
Ver original
  1. <?php
  2. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  3.   foreach($_POST["clave3"] as $key => $value){
  4.   $updateSQL = sprintf("insert into pagos ( .....) values (%s, %s,%s)",
  5.                
  6.                        GetSQLValueString($_POST['clave3'][$key],  "text"),
  7.             GetSQLValueString($_POST['conceptot'][$key], "text"),
  8.             GetSQLValueString($_POST['recibi'][$key],  "text"));
  9.                        
  10.   mysql_select_db($database_connection, $connection);
  11.   $Result1 = mysql_query($updateSQL, $connection) or die(mysql_error());
  12.  
  13.   $insertGoTo = "MensualidadesP.php";
  14.  
  15. mysql_select_db($database_connection, $connection);
  16. $query_alumnos = sprintf("SELECT * FROM ... ORDER BY id_pago"
  17. , GetSQLValueString($colname_alumnos, "text"));
  18. $alumnos = mysql_query($query_alumnos, $connection) or die(mysql_error());
  19. $row_alumnos = mysql_fetch_assoc($alumnos);
  20. $totalRows_alumnos = mysql_num_rows($alumnos);
  21.  
  22.  
  23. ?>
  24.  
  25. ...
  26. <body bgcolor="#ffffff">
  27. <table  border="0" cellpadding="0" cellspacing="0" width="1280" align="center">
  28.  
  29.  
  30.  ....
  31.    <form action="<?php echo $editFormAction; ?>" method="post"  name="form1" id="form1" >
  32.  
  33.  <input type="hidden" name="clave3[]" id="clave3" value="<? echo $row_clientes['cliente']; ?>" size="10" />
  34.    <?php
  35.    
  36.     $action = isset($_GET['action']) ? $_GET['action'] : "";
  37.     $alumno = ($_GET['cliente']);
  38.    
  39.     if($action=='removed'){
  40.         echo "<div>" . $_GET['name'] . " Eliminado.</div>";
  41.     }
  42.    
  43.     if(isset($_SESSION['cart'])){
  44.         $ids = "";
  45.    
  46.        
  47.         foreach($_SESSION['cart'] as $id){
  48.             $ids = $ids . $id . ",";
  49.         }
  50.        
  51.    
  52.         $ids = rtrim($ids, ',');
  53.        
  54.         require "libs/DbConnect.php";
  55.  
  56.         $query = "SELECT * FROM ... where idcole IN ({$ids})";
  57.         $stmt = $con->prepare( $query );
  58.         $stmt->execute();
  59.  
  60.         $num = $stmt->rowCount();
  61.  
  62.         if($num>0){
  63.             echo "<table border='0' class='pagos'>";
  64.                  
  65.                
  66.                 echo "<tr>";
  67.                     echo "<th class='textAlignLeft'>Mes</th>";
  68.                      echo "<th></th>";
  69.                     echo "<th>Monto</th>";
  70.                     echo "<th>Borrar</th>";
  71.                 echo "</tr>";
  72.                
  73.            
  74.                 $totalPrice = 0;
  75.                  
  76.                
  77.                 while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
  78.                     extract($row);
  79.                    
  80.                    
  81.                    
  82.                
  83.                     echo "<tr>";
  84.                    
  85.                         echo "<td><input name='conceptot[]' id='nombre' type='hidden'   size='15' value='{$Mes}'  />";
  86.                    
  87.                    
  88.                         echo "</td>";
  89.                        
  90.                            
  91.                 echo "<td align='left'>Recibi:</td>";
  92.                    
  93.                      echo "<td><input name='recibi[]' id='recibi' type='text'   size='15' value=''  />
  94. </td>";
  95.            
  96.                     echo "</th>";
  97.                
  98.             echo "</table>";
  99.            
  100.         }else{
  101.             echo "<div>No hay mensualidades seleccionadas</div>";
  102.         }
  103.  
  104.     }else{
  105.         echo "<div>No hay mensualidades</div>";
  106.     }
  107.     ?>
  108.  
  109.  
  110.  <input type="hidden" name="MM_insert" value="form1" />
  111. </form>

Última edición por Triby; 10/02/2014 a las 18:06 Razón: Código en highlight