Ver Mensaje Individual
  #2 (permalink)  
Antiguo 06/04/2006, 03:55
Avatar de chiquirf
chiquirf
 
Fecha de Ingreso: noviembre-2005
Ubicación: Madrid
Mensajes: 215
Antigüedad: 20 años, 10 meses
Puntos: 3
..... continua



ARCHIVO prueba-lista.php
Código PHP:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_Procedimientos = "localhost";
$database_Procedimientos = "pros_soporte";
$username_Procedimientos = "carlos";
$password_Procedimientos = "carlos";
$Procedimientos = mysql_pconnect($hostname_Procedimientos, $username_Procedimientos, $password_Procedimientos) or trigger_error(mysql_error(),E_USER_ERROR); 
?>



<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 pruebas SET nombre=%s, fecha=%s WHERE ID=%s",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['fecha'], "date"),
                       
GetSQLValueString($_POST['ID'], "int"));

  
mysql_select_db($database_Procedimientos, $Procedimientos);
  
$Result1 = mysql_query($updateSQL, $Procedimientos) or die(mysql_error());

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


$idprueba = $_GET['pruebaid'];
mysql_select_db($database_Procedimientos, $Procedimientos);
$query_pruebas = "SELECT * FROM pruebas WHERE ID='".$idprueba."'";
$pruebas = mysql_query($query_pruebas, $Procedimientos) or die(mysql_error());
$row_pruebas = mysql_fetch_assoc($pruebas);
$totalRows_pruebas = mysql_num_rows($pruebas);


// FECHA............. INI
$hoy=strftime("%d/%m/%Y");
function 
cambiaf_a_mysql($hoy){ 
    
ereg( "([0-9]{1,2})/([0-9]{1,2})/([0-9]{2,4})", $hoy, $mifecha); 
    
$hoymysql=$mifecha[3]."-".$mifecha[2]."-".$mifecha[1]; 
    return 
$hoymysql; 
}

function 
cambiaf_a_normal($fecha){ 
    
ereg( "([0-9]{2,4})-([0-9]{1,2})-([0-9]{1,2})", $fecha, $mifecha); 
    
$lafecha=$mifecha[3]."/".$mifecha[2]."/".$mifecha[1]; 
    return 
$lafecha; 
} 

// FECHA............. FIN

?>

<html >
<head>

</head>

<body>
Editar<br />
<br />
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table align="left">
    <tr valign="baseline">
      <td nowrap align="right">ID:</td>
      <td><?php echo $row_pruebas['ID']; ?></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Nombre:</td>
      <td><input type="text" name="nombre" value="<?php echo $row_pruebas['nombre']; ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Fecha:</td>
      <td><input type="text" name="fecha" value="<?php echo cambiaf_a_normal($row_pruebas['fecha']); ?>" size="32"> dd/mm/aaaa</td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="Actualizar registro"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="ID" value="<?php echo $row_pruebas['ID']; ?>">
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result
($pruebas);
?>

..... falta la base de datos

continua.......