Este es un código donde me genera una tabla donde se elige el dato a modificar :
Código PHP:
<!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>
<title>Disfruta</title>
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="simpletreemenu.js"></script>
<link rel="stylesheet" type="text/css" href="simpletree.css" />
</head>
<body>
<?php
include("../Connections/conexion.php");
echo "<table class=\"chica\" align=\"center\" border=\"1px\">
<tr>
<th><b>id</b></th>
<th><b>Nombre</b></th>
<th><b>Editar</b></th>
</tr>";
$sql = mysql_query("SELECT id_paq,nombre_paquete from paquetes") or die(mysql_error());
// mostramos los registros
while($row = mysql_fetch_array($sql)){
echo "<tr>";
echo "<td>".$row["id_paq"] ."</td>";
echo "<td>".$row["nombre_paquete"] ."</td>";
echo "<td><a href='ver.php?id=$row[id_paq]'><img src=\"imagenes/editar.png\" width=\"15px\" height=\"15px\" alt=\"Buscar\" title=\"Ver\"></a>\n</td>";
}
echo "</table>";
?>
Este es el formulario por medio del cual editaran:
Código PHP:
<?php
include("../Connections/conexion.php");
$sql = mysql_query("SELECT * FROM paquetes_disfruta2014mal WHERE id_paq = $id") or die(mysql_error());
while($row = mysql_fetch_array($sql)){
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="es">
<head>
<link href="calendario_dw/calendario_dw-estilos.css" type="text/css" rel="STYLESHEET">
<style type="text/css">
body{
font-family: arial, arial, sans-serif;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="calendario_dw/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="calendario_dw/calendario_dw.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".campofecha").calendarioDW();
})
</script>
</head>
<!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=utf-8" />
</head>
<body>
<form name="valida" action="ver2.php" method="post">
<table>
<tr><td><p> </p></td> <td><p><label for="fecha_captura"></label><input name="opcion" type="hidden" name"fecha_captura" size="12" name="fecha_captura" value="<?php echo date("d-m-Y");?>"</p></td></tr>
<tr><td> <p>Nombre del Paquete:</p></td><td><p><label for="nombre_paquete"></label><input type="text" name="nombre_paquete" value="<?php echo $row['nombre_paquete']; ?>" id="nombre_paquete"/></p></td></tr>
<tr><td> <p>Vigencia: </p></td><td><input type="text" name="vigencia" value="<?php echo $row['vigencia']; ?>" id="vigencia" class="campofecha" size="12"></p></td></tr>
<tr><td> <p>Nombre de la Agencia/Turoperadora:</p></td><td><p><label for="agencia"></label><input type="text" name="agencia" value="<?php echo $row['agencia']; ?>" id="agencia" /></p></td></tr>
<tr><td> <p>Precio Desde:</p></td><td><p><label for="precio"></label><input type="text" name="precio" value="<?php echo $row['precio']; ?>" id="precio" /></p></td></tr>
<script type="text/javascript">
$(document).ready(function(){
// Función a lanzar cada vez que se presiona una tecla en un textarea
// en el que se encuentra el atributo maxlength
$("textarea[maxlength]").keyup(function() {
var limit = $(this).attr("maxlength"); // Límite del textarea
var value = $(this).val(); // Valor actual del textarea
var current = value.length; // Número de caracteres actual
if (limit < current) { // Más del límite de caracteres?
// Establece el valor del textarea al límite
$(this).val(value.substring(0, limit));
}
});
});
</script>
<tr><td> <p>Descripcion (breve):</p></td><td><p><label for="descripcion"></label><textarea maxlength="150" cols="40" rows="10" onkeyup="return ismaxlength(this)" name="descripcion" id="descripcion" rows="10" cols="20" ><?php if ($row[$textopat]==''){echo nl2br($row['descripcion']);} else {echo nl2br($row[$textopat]);}?></textarea></p></td></tr>
<tr><td> <p>Duracion del Paquete:</p></td> <td><p><label for="duracion"></label><input type="text" name="duracion" value="<?php echo $row['duracion']; ?>" id="duracion" /></p></td></tr>
<tr><td> <p>Categoria</p></td><td><p><label for="categoria"></label><input type="text" name="categoria" value="<?php echo $row['categoria']; ?>" id="categoria" /></p></td></tr>
<tr><td> <p>Incluye: </p></td> <td><p><label for="incluye"></label><textarea name="incluye" id="incluye" rows="5" cols="40"><?php if ($row[$textopat]==''){echo nl2br($row['incluye']);} else {echo nl2br($row[$textopat]);}?></textarea></p></td></tr>
<tr><td> <p>No Incluye: </p></td><td><p><label for="no_incluye"></label><textarea name="no_incluye" id="no_incluye" rows="5" cols="40"><?php if ($row[$textopat]==''){echo nl2br($row['no_incluye']);} else {echo nl2br($row[$textopat]);}?></textarea></p></td></tr>
<tr><td> <p>Observaciones: </p></td><td><p><label for="observaciones"></label><textarea name="observaciones" id="observaciones" rows="5" cols="40"><?php if ($row[$textopat]==''){echo nl2br($row['observaciones']);} else {echo nl2br($row[$textopat]);}?></textarea></p></td></tr>
<tr><td> <p>Notas: </p></td><td><p><label for="notas"></label><textarea name="notas" id="notas" rows="5" cols="40"><?php if ($row[$textopat]==''){echo nl2br($row['notas']);} else {echo nl2br($row[$textopat]);}?></textarea></p></td></tr>
<tr><td> <p>Telefono: </p></td><td><p><label for="telefono"></label><input type="text" name="telefono" value="<?php echo $row['telefono']; ?>" id="telefono" /></p></td></tr>
<tr><td> <p>Correo Electrónico: </p></td><td><p><label for="email"></label><input type="text" name="email" value="<?php echo $row['email']; ?>" id="email" /></p></td></tr>
<tr><td> <p>Página Web: </p></td><td><p><label for="web"></label><input type="text" name="web" value="<?php echo $row['web']; ?>" id="web" value="" /></p></td></tr>
</table>
<p> </p>
<tr><td colspan="4" align="center"><input type="submit" name="actualizar" value="Actualizar" />
<input type="button" value="Regresar" onclick="window.location.href='index.php'" />
</td></tr>
</form>
</table>
<?php }?>
Código PHP:
<?php
include("../Connections/secturdf.php");
$fecha_captura = date("d/m/Y");
$vigencia = $_POST["vigencia"];
$nombre_paquete = $_POST["nombre_paquete"];
$agencia = $_POST["agencia"];
$precio = $_POST["precio"];
$descripcion = $_POST["descripcion"];
$duracion = $_POST["duracion"];
$categoria = $_POST["categoria"];
$incluye = $_POST["incluye"];
$no_incluye = $_POST["no_incluye"];
$observaciones = $_POST["observaciones"];
$notas = $_POST["notas"];
$telefono = $_POST["telefono"];
$email = $_POST["email"];
$web = $_POST["web"];
$id_paq = $_POST["id_paq"];
$update1 = mysql_query("UPDATE paquetes_disfruta2014mal SET fecha_captura = '$fecha_captura', vigencia = '$vigencia',
nombre_paquete = '$nombre_paquete',agencia = '$agencia', precio = '$precio', descripcion = '$descripcion',
duracion = '$duracion', categoria = '$categoria', incluye = '$incluye', no_incluye = '$no_incluye', observaciones = '$observaciones',
notas= '$notas', telefono = '$telefono', email = '$email', web = '$web' WHERE id_paq = '$id_paq'") or die(mysql_error());
echo"<script>
alert('Informacion Editada');
document.location.href='editar.php';
</script>"; ?>