Ver Mensaje Individual
  #5 (permalink)  
Antiguo 27/06/2016, 09:06
mortisdj
 
Fecha de Ingreso: mayo-2014
Ubicación: Valencia
Mensajes: 63
Antigüedad: 10 años
Puntos: 0
Respuesta: Actualizar datos en la base de datos desde PHP

Cita:
Iniciado por iniciopublic Ver Mensaje
Muestra el código donde haces el update
Código PHP:
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$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;
}
}
$varcentro 0;
if (  isset(
$_GET['recordId']) && $_GET['recordId'] !=''){
$varcentro =    $_GET['recordId'];
}

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

if ((isset(
$_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  
$insertSQL sprintf("UPDATE tbllibro SET strLibro=%s, strPrecio=%s, strAno=%s, strVentas=%s, strvVentas=%s, strDerechos=%s, strvDerechos=%s, strRetencion=%s, strValorRetencion=%s, strNeto=%s, intCliente=%s, strObserva=%s, strFecha=%s, intCliente=%s WHERE intLibro=%s",
                       
GetSQLValueString($_POST['strLibro'], "text"),
                       
GetSQLValueString($_POST['strPrecio'], "float"),
                       
GetSQLValueString($_POST['strAno'], "text"),
                       
GetSQLValueString($_POST['strVentas'], "int"),
                       
GetSQLValueString($_POST['strvVentas'], "float"),        
                       
GetSQLValueString($_POST['strDerechos'], "text"),
                       
GetSQLValueString($_POST['strvDerechos'], "float"),
                       
GetSQLValueString($_POST['strRetencion'], "int"),
               
GetSQLValueString($_POST['strValorRetencion'], "float"),
               
GetSQLValueString($_POST['strNeto'], "float"),               
               
GetSQLValueString($_POST['intCliente'], "intCliente"),                                           
               
GetSQLValueString($_POST['strObserva'], "text"),
                       
GetSQLValueString($_POST['strFecha'], "text"),
               
GetSQLValueString($_POST['intLibro'], "int"));
                       
  
mysql_select_db($database_conexion$conexion);
  
$Result1 mysql_query($insertSQL$conexion) or die(mysql_error());
  
  
$updateGoTo "clientes-list.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$updateGoTo .= (strpos($updateGoTo'?')) ? "&" "?";
    
$updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$updateGoTo));
}


$UsuarioId_ModificarDatos "0";
if (isset(
$_GET['recordId'])) {
  
$UsuarioId_DatosCentros2 $_GET['recordId'];
}

mysql_select_db($database_conexion$conexion);
$query_DatosCentros "SELECT * FROM tblclientes";
$DatosCentros mysql_query($query_DatosCentros$conexion) or die(mysql_error());
$row_DatosCentros mysql_fetch_assoc($DatosCentros);
$totalRows_DatosCentros mysql_num_rows($DatosCentros);

mysql_select_db($database_conexion$conexion);
$query_DatosCentros2 sprintf("SELECT * FROM tbllibro WHERE tbllibro.intLibro= %s"GetSQLValueString($varcentro"int"));
$DatosCentros2 mysql_query($query_DatosCentros2$conexion) or die(mysql_error());
$row_DatosCentros2 mysql_fetch_assoc($DatosCentros2);
$totalRows_DatosCentros2 mysql_num_rows($DatosCentros2);

?>