Ver Mensaje Individual
  #11 (permalink)  
Antiguo 06/01/2011, 11:38
dasa
 
Fecha de Ingreso: marzo-2009
Mensajes: 132
Antigüedad: 15 años, 1 mes
Puntos: 8
Respuesta: Insertar multiples Registros

Tengo casi el mismo problema donde tengo dos paginas la primera busca y la segunda muestra resultados con un repetir región, tengo un campo de texto el cual es el que necesito llenar unicamente lo demás dejar igual sin modificar.

Realice el proceso del loop y arregle los errores que me decia pero no he podido actualizar, ya que no me guarda nada en el campo entregada.

Este es el codigo:

Cita:
<?php require_once('Connections/pailinea.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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_update"])) && ($_POST["MM_update"] == "form1")) {

foreach($_POST["cod_ips1"] as $key => $value){

$updateSQL = sprintf("UPDATE pedidos SET entregada=%s WHERE cod_ips=%s",
GetSQLValueString($_POST['despachada'] [$key], "text"),
GetSQLValueString($_POST['cod_ips'] [$key], "int"));

mysql_select_db($database_pailinea, $pailinea);
$Result1 = mysql_query($updateSQL, $pailinea) or die(mysql_error());

$updateGoTo = "ejebusca.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
}
$maxRows_MostrarPedido = 10;
$pageNum_MostrarPedido = 0;
if (isset($_GET['pageNum_MostrarPedido'])) {
$pageNum_MostrarPedido = $_GET['pageNum_MostrarPedido'];
}
$startRow_MostrarPedido = $pageNum_MostrarPedido * $maxRows_MostrarPedido;

$colname_MostrarPedido = "-1";
if (isset($_GET['cod_ips'])) {
$colname_MostrarPedido = $_GET['cod_ips'];
}
mysql_select_db($database_pailinea, $pailinea);
$query_MostrarPedido = sprintf("SELECT * FROM pedidos WHERE cod_ips = %s", GetSQLValueString($colname_MostrarPedido, "int"));
$query_limit_MostrarPedido = sprintf("%s LIMIT %d, %d", $query_MostrarPedido, $startRow_MostrarPedido, $maxRows_MostrarPedido);
$MostrarPedido = mysql_query($query_limit_MostrarPedido, $pailinea) or die(mysql_error());
$row_MostrarPedido = mysql_fetch_assoc($MostrarPedido);

if (isset($_GET['totalRows_MostrarPedido'])) {
$totalRows_MostrarPedido = $_GET['totalRows_MostrarPedido'];
} else {
$all_MostrarPedido = mysql_query($query_MostrarPedido);
$totalRows_MostrarPedido = mysql_num_rows($all_MostrarPedido);
}
$totalPages_MostrarPedido = ceil($totalRows_MostrarPedido/$maxRows_MostrarPedido)-1;

mysql_select_db($database_pailinea, $pailinea);
$query_ObtenerIPS = "SELECT ips.cod_ips, ips.nombre, pedidos.cod_ips FROM ips, pedidos WHERE ips.cod_ips = pedidos.cod_ips";
$ObtenerIPS = mysql_query($query_ObtenerIPS, $pailinea) or die(mysql_error());
$row_ObtenerIPS = mysql_fetch_assoc($ObtenerIPS);
$totalRows_ObtenerIPS = mysql_num_rows($ObtenerIPS);

$colname_Recordset1 = "-1";
if (isset($_GET['cod_ips'])) {
$colname_Recordset1 = $_GET['cod_ips'];
}
mysql_select_db($database_pailinea, $pailinea);
$query_Recordset1 = sprintf("SELECT cod_ips, nombre FROM ips WHERE cod_ips = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $pailinea) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
<link href="estilo/styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.Estilo1 {color: #000000}
.Estilo2 {color: #FF0000}
.botonExcel {cursor:pointer;}
-->
</style>
</head>

<body>
<p>&nbsp;</p>

<?php if ($totalRows_MostrarPedido > 0) { // Show if recordset not empty ?>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<?php echo $row_Recordset1['nombre']; ?>
<table width="792" border="0" align="center" id="Exportar_a_Excel">
<tr>
<td width="143" class="text3"><div align="center"><span class="Estilo1">Fecha de Solicitud</span></div></td>
<td width="123" class="text3"><div align="center"><span class="Estilo1">Suministro</span></div></td>
<td width="135" class="text3"><div align="center"><span class="Estilo1">Presentación</span></div></td>
<td width="153" class="text3"><div align="center"><span class="Estilo1">Casa Productora</span></div></td>
<td width="116" class="text3"><div align="center"><span class="Estilo1">Cantidad</span></div></td>
<td width="96" class="text3"><div align="center"><span class="Estilo1">Despachada</span></div></td>
</tr>
<?php do { ?>
<tr class="text3">
<td class="Estilo2"><div align="center"><?php echo $row_MostrarPedido['fecha_solicitud']; ?></div></td>
<td class="Estilo2"><div align="center"><?php echo $row_MostrarPedido['suministro']; ?></div></td>
<td class="Estilo2"><div align="center"><?php echo $row_MostrarPedido['presentacion']; ?></div></td>
<td class="Estilo2"><div align="center"><?php echo $row_MostrarPedido['casa_productora']; ?></div></td>
<td class="Estilo2"><div align="center"><?php echo $row_MostrarPedido['cantidad']; ?></div></td>
<td class="Estilo2"><label>
<div align="center">
<input name="despachada" type="text" class="Estilo1" id="despachada" value="<?php echo $row_MostrarPedido['entregada']; ?>" />
</div> </label></td>
</tr>
<?php } while ($row_MostrarPedido = mysql_fetch_assoc($MostrarPedido)); ?>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<label>
<input type="submit" name="registrar" id="registrar" value="Enviar" />
</label>
<input name="cod_ips" type="hidden" id="cod_ips" value="<?php echo $row_MostrarPedido['cod_ips']; ?>" />
<input name="cod_ips1[]" type="hidden" id="cod_ips1" value="<?php echo $despachada ?>" />
<input type="hidden" name="MM_update" value="form1" />
</form>
<?php } // Show if recordset not empty ?>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($MostrarPedido);

mysql_free_result($ObtenerIPS);

mysql_free_result($Recordset1);
?>