Ver Mensaje Individual
  #22 (permalink)  
Antiguo 02/11/2010, 11:16
cesar31
 
Fecha de Ingreso: octubre-2010
Mensajes: 26
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: Tratando de update a Record from MySql

Saludo este es el codigo php:

<html>
<head>
<style type="text/css">
body
{
background:navy;color:yellow;}
}
h2 {color:#a5d8f6;}
</style>
</head>


<html>
<Body>
<h1><b><big> Actualizar Record <h1>

<form>
<?php

$con = mysql_connect("localhost","root","");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("hoja", $con);
$Estudiante= "'".$_POST['Estudiante']."'";
$result = mysql_query("SELECT * FROM hr WHERE Numero=$Estudiante");
$row = mysql_fetch_array($result); ?>
Numero de Estudiante:
<input type="text" name="Estudiante" value="<?php echo ($Estudiante);?> "/>
Nombre:
<input type="text" name="nombre" value="<?php echo ($row['Nombre']);?> " />
Fecha:
<input type="text" name="fecha" value="<?php echo ($row['Fecha']);?> " />
<br/>

<input type="submit" value="Continuar" />
</form>
</html>

y este es el otro codigo php que estoty utilizando para que guarde la actualización:
<?php

//echo $_POST["fecha"].",".$_POST["consultor"];

$con = mysql_connect("localhost","root","");

if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("hoja",$con);


$Estudiante="'".$_POST['Estudiante']."'";
$nombre="'".$_POST['nombre']."'";
$fecha="'".$_POST['fecha']."'";
$sql = "INSERT INTO hr (Numero,Nombre,Fecha) VALUES ($Estudiante,$nombre,$fecha)";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}

echo "1 record updated";

//mysql_close($con);

?>

<html>
<body>

<a href="http://localhost/xampp/hr/index.html">Proximo Record</a>
</body>
</html>

Gracias por tu ayuda