Ver Mensaje Individual
  #5 (permalink)  
Antiguo 23/08/2010, 05:02
gomminola
 
Fecha de Ingreso: mayo-2008
Mensajes: 253
Antigüedad: 15 años, 10 meses
Puntos: 8
Respuesta: Accion reemplazar mysql

esto...dejo el codigo completo, lo primero

Cita:
<?php
$state = false;
if ($_POST['action'] == "add") {
$conexion = mysql_connect("local", "root", "pass");
mysql_select_db("db", $conexion);

$que = "INSERT INTO menu1 (menu1) ";
$que.= "VALUES ('".$_POST['nombre']."') ";
$res = mysql_query($que, $conexion) or die(mysql_error());
$state = true;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Insertar datos en MySQL</title>
<style type="text/css">
<!--
body {
font-family: "Trebuchet MS", Tahoma, Arial;
font-size: 12px;
color: #333333;
}
h2 {
font-size: 16px;
color: #CC0000;
}
input, select {
font-family: "Trebuchet MS", Tahoma, Arial;
font-size: 11px;
color: #666666;
}
-->
</style>
</head>
<body>
<h2>Insertar datos en MySQL</h2>
<form id="insertar" name="insertar" method="post" action="">
<p>Nombre:
<input name="nombre" type="text" id="nombre" size="50" />
<input type="submit" name="Submit" value="Insertar Registro" />
<input type="hidden" name="action" value="add" />
</p>
</form>

<?php
$queEmp = "SELECT * FROM menu1 ORDER BY menu1 ASC";
$resEmp = mysql_query($queEmp, $conexion) or die(mysql_error());
$totEmp = mysql_num_rows($resEmp);
if ($totEmp> 0) {
while ($rowEmp = mysql_fetch_assoc($resEmp)) {

echo $rowEmp['menu1']."<br>";

}
}
?>
<?php if ($state) { ?>
<?php } ?>
</body>
</html>
y yo lo qque quiero es k de primera me ingrese el primer registro, pero luego si quiero hacer algun cambio lo reemplaza y no k m ingrese otro registro.