Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/03/2009, 16:32
PaoValencia
 
Fecha de Ingreso: marzo-2009
Mensajes: 24
Antigüedad: 15 años, 1 mes
Puntos: 0
Actualizar Datos por medio de Recordset

Hola a todos, estoy realizando una actualización de datos por medio de recordset en dreamweaver, se requiere un código para que muestre los datos que tiene ese código y sobre ellos poder modificar y actualizar, el proceso lo realiza bien, pero quisiera saber en que parte coloco mensajes de validación primero para que muestre si el codigo lo encontro o no y el otro para que cuando le da a la opcion actualizar me muestre otro mensaje de que se pudo actualizar.
Estoy utilizando PHP y MySQL, si alguien sabe por favor ayudeme con esto, gracias.
Adjunto el código


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;
}
}

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

if ((isset(
$_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
  
$updateSQL sprintf("UPDATE estudiante SET nombre=%s, apellido=%s, dir_domicilio=%s, tel_domicilio=%s, dir_oficina=%s, tel_oficina=%s WHERE cod_estudiante=%s",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['apellido'], "text"),
                       
GetSQLValueString($_POST['dir_domicilio'], "text"),
                       
GetSQLValueString($_POST['tel_domicilio'], "int"),
                       
GetSQLValueString($_POST['dir_oficina'], "text"),
                       
GetSQLValueString($_POST['tel_oficina'], "text"),
                       
GetSQLValueString($_POST['cod_estudiante'], "int"));

  
mysql_select_db($database_notas$notas);
  
$Result1 mysql_query($updateSQL$notas) or die(mysql_error());
}

$colname_Recordset2 "-1";
if (isset(
$_POST['cod_estudiante'])) {
  
$colname_Recordset2 $_POST['cod_estudiante'];
}
mysql_select_db($database_notas$notas);
$query_Recordset2 sprintf("SELECT * FROM estudiante WHERE cod_estudiante = %s"GetSQLValueString($colname_Recordset2"int"));
$Recordset2 mysql_query($query_Recordset2$notas) or die(mysql_error());
$row_Recordset2 mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 mysql_num_rows($Recordset2);
?>

Última edición por PaoValencia; 15/03/2009 a las 20:10