Ver Mensaje Individual
  #10 (permalink)  
Antiguo 20/04/2011, 12:20
goyitoparana
 
Fecha de Ingreso: agosto-2009
Mensajes: 72
Antigüedad: 14 años, 8 meses
Puntos: 2
Respuesta: Cargar multiples registros a la misma tabla

A ver, lo he logrado de la siguiente manera... pero a mi parecer se sobrecarga demasiado el servidor... quiero ver que opinan....

Código PHP:
Ver original
  1. $editFormAction = $_SERVER['PHP_SELF'];
  2. if (isset($_SERVER['QUERY_STRING'])) {
  3.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  4. }
  5.  
  6. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  7.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",
  8.                        GetSQLValueString($_POST['textfield'], "date"), GetSQLValueString($_POST['textfield31'], "double"));
  9.                        mysql_select_db($database_conexion, $conexion);
  10.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  11.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",                     
  12.                        GetSQLValueString($_POST['textfield2'], "date"), GetSQLValueString($_POST['textfield32'], "double"));
  13.  $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",
  14.                        GetSQLValueString($_POST['textfield3'], "date"), GetSQLValueString($_POST['textfield33'], "double"));
  15.                        mysql_select_db($database_conexion, $conexion);
  16.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  17.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",  
  18.                        GetSQLValueString($_POST['textfield4'], "date"), GetSQLValueString($_POST['textfield34'], "double"));
  19.                        mysql_select_db($database_conexion, $conexion);
  20.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  21.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",  
  22.                        GetSQLValueString($_POST['textfield5'], "date"), GetSQLValueString($_POST['textfield35'], "double"));
  23.                        mysql_select_db($database_conexion, $conexion);
  24.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  25.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",  
  26.                        GetSQLValueString($_POST['textfield6'], "date"), GetSQLValueString($_POST['textfield36'], "double"));                                                                               
  27.                        mysql_select_db($database_conexion, $conexion);
  28.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  29.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",  
  30.                        GetSQLValueString($_POST['textfield7'], "date"), GetSQLValueString($_POST['textfield37'], "double"));
  31.                        mysql_select_db($database_conexion, $conexion);
  32.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  33.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",  
  34.                        GetSQLValueString($_POST['textfield8'], "date"), GetSQLValueString($_POST['textfield38'], "double"));
  35.                        mysql_select_db($database_conexion, $conexion);
  36.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  37.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",  
  38.                        GetSQLValueString($_POST['textfield9'], "date"), GetSQLValueString($_POST['textfield39'], "double"));
  39.                        mysql_select_db($database_conexion, $conexion);
  40.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  41.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",  
  42.                        GetSQLValueString($_POST['textfield10'], "date"), GetSQLValueString($_POST['textfield40'], "double"));
  43.                        mysql_select_db($database_conexion, $conexion);
  44.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  45.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",  
  46.                        GetSQLValueString($_POST['textfield11'], "date"), GetSQLValueString($_POST['textfield41'], "double"));
  47.                        mysql_select_db($database_conexion, $conexion);
  48.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  49.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",  
  50.                        GetSQLValueString($_POST['textfield12'], "date"), GetSQLValueString($_POST['textfield42'], "double"));
  51.                        mysql_select_db($database_conexion, $conexion);
  52.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
  53.   $insertSQL = sprintf("INSERT INTO indices (indice_fecha, indice_valor) VALUES (%s, %s)",  
  54.                        GetSQLValueString($_POST['textfield13'], "date"), GetSQLValueString($_POST['textfield43'], "double"));                                                                                                                          
  55.                        mysql_select_db($database_conexion, $conexion);
  56.                        $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());


No se sobrecarga demasiado el server?