Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/03/2008, 07:28
Jhorb
 
Fecha de Ingreso: junio-2002
Mensajes: 261
Antigüedad: 21 años, 10 meses
Puntos: 0
Re: Update de varios registros desde un combo

Hola a todos, este es el código PHP que DW generó, el cual deseo modificar de manera manual para que todos los registros en pantalla se actualicen en un solo proceso. Solicito colaboración de los duros de PHP por favor!!!!

Código 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")) {
  
$updateSQL sprintf("UPDATE generar SET Calificacion=%s WHERE Num_Auditoria=%s AND numpregunta=%s",
                       
GetSQLValueString($_POST['CmbCalifica'], "int"),
                       
GetSQLValueString($_POST['numero1'], "int"),
                       
GetSQLValueString($_POST['CodPregunta'], "int"));

  
mysql_select_db($database_Audito$Audito);
  
$Result1 mysql_query($updateSQL$Audito) or die(mysql_error());

  
/*Este update fue manual, no generado por DW*/
  
$updateSQL sprintf("UPDATE auditoria SET activo=1 WHERE numero=%s",
                       
GetSQLValueString($_POST['numero1'], "int"));

  
mysql_select_db($database_Audito$Audito);
  
$Result1 mysql_query($updateSQL$Audito) or die(mysql_error());

  
$updateGoTo "pregalmacenadas2.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$updateGoTo .= (strpos($updateGoTo'?')) ? "&" "?";
    
$updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$updateGoTo));
}

$NumAudito_RecPregAuditoria "-1";
if (isset(
$_POST['numero'])) {
  
$NumAudito_RecPregAuditoria = (get_magic_quotes_gpc()) ? $_POST['numero'] : addslashes($_POST['numero']);
  
//echo $NumAudito_RecPregAuditoria;
}
$colname_RecPregAuditoria "-1";
if (isset(
$_POST['numero'])) {
  
$colname_RecPregAuditoria = (get_magic_quotes_gpc()) ? $_POST['numero'] : addslashes($_POST['numero']);
}
mysql_select_db($database_Audito$Audito);
$query_RecPregAuditoria sprintf("SELECT * FROM generar WHERE Num_Auditoria = %s"GetSQLValueString($colname_RecPregAuditoria"int"));
$RecPregAuditoria mysql_query($query_RecPregAuditoria$Audito) or die(mysql_error());
$row_RecPregAuditoria mysql_fetch_assoc($RecPregAuditoria);
$totalRows_RecPregAuditoria mysql_num_rows($RecPregAuditoria);
?>
__________________
Buscando el camino...