Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/10/2009, 18:41
victorross
 
Fecha de Ingreso: octubre-2009
Mensajes: 6
Antigüedad: 14 años, 7 meses
Puntos: 0
Respuesta: Ayuda! Insertar registro varias veces.

Gracias por tu rápida respuesta, creo que entiendo lo que me decis, pero como soy bastante nuevo necesito que me aclares algunas dudas si podes...
Al campo donde voy a poner la cantidad de veces que quiero insertar el registro que estoy completando ¿lo ubico fuera del FORM? seria algo asi:
Código:
<input type="text" name="$cantidad_de_veces_a_insertar" size="5">
Y mi otra duda seria el codigo que tengo arriba para hacer el INSERT es el siguiente:
Código:
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO stock (Equipo, Temp, TitSup, Estampado, Talle, Mangas, Precio, `Day`, `Month`, `Year`, Notas) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Equipo'], "text"),
                       GetSQLValueString($_POST['Temp'], "text"),
                       GetSQLValueString($_POST['TitSup'], "text"),
                       GetSQLValueString($_POST['Estampado'], "text"),
                       GetSQLValueString($_POST['Talle'], "text"),
                       GetSQLValueString($_POST['Mangas'], "text"),
                       GetSQLValueString($_POST['Precio'], "int"),
                       GetSQLValueString($_POST['Day'], "int"),
                       GetSQLValueString($_POST['Month'], "text"),
                       GetSQLValueString($_POST['Year'], "int"),
                       GetSQLValueString($_POST['Notas'], "text"));

  mysql_select_db($database_Conexion, $Conexion);
  $Result1 = mysql_query($insertSQL, $Conexion) or die(mysql_error());

  $insertGoTo = "bdd_stock.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
Por lo que no estoy seguro donde iria el "for($i = 0..."
Osea de tanto leer y buscar entiendo claramente el código que me pasas, pero no estoy seguro en que parte colocarlo, si me podrias ayudar con eso te estaria muy agradecido.
Saludos!