Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/06/2008, 15:17
Avatar de Fogox
Fogox
 
Fecha de Ingreso: abril-2008
Mensajes: 59
Antigüedad: 16 años
Puntos: 0
Pregunta Pregunta por abm no puedo actualizar al usuario...

Buenas, consulta sobre mi abm, no consigo que pase la variable a modificar aqui les muestro el codigo...

Muestro al usuario....
Código PHP:
<?php 

include ('conexion.php');

echo 
'<p>'."muestra usuarios";

    
        
$rs mysql_query("select Id, Nombre , Apellido, Direccion, Telefono from datos");
    
?>
    <table border="1">
    <tr>
    <th>Id</th>
    <th>Nombre</th>
    <th>Apellido</th>
    <th>Direccion</th>
    <th>Telefono</th>
    </tr>
    <?php

        
while (list($Id$Nombre$Apellido$Direccion$Telefono) = mysql_fetch_row($rs)) {
    
?>
    <tr>
    <td><a href="actualiza_usuario.php?id= <?= $Id ?>"><?= $Id ?></td>
    <td><?= $Nombre ?></td>
    <td><?= $Apellido ?></td>
    <td><?= $Direccion ?></td>
    <td><?= $Telefono ?></td>
    </tr>
    <?
        
}
    
?>
    </table>

<form action="actualiza_usuario.php?id=" method="post">
<input type="submit" value="actualizar usuario" />
</form>
Aqui tomaria la variable seleccionada para modificar....

actualizar_usuario.php


Código PHP:
<?php
include ('conexion.php');
echo 
'<p>';
echo 
'actualiza usuario'.'<p>';

    
//    $rs = mysql_query("select Nombre, Apellido, Direccion, Telefono from datos where Id = $id");
    
$rs mysql_query("select Nombre, Apellido, Direccion, Telefono from datos where Id='$id'");
    list(
$nombre,$apellido,$direccion,$telefono) = mysql_fetch_row($rs);





?>

<?php echo $nombre ?>
<h2>Actualiza Cliente <?= $nombre ?></h2>
<a href="actualizar.php?id=<?= $id ?>">Actualiza</a>

<br>
<br>
<form action="cliente_actualizar.php" method="post">
<input type="hidden" name="id" value="<?= $id ?>">
<table>
<tr>
<td>Id</td>
<td><?= $id ?></td>
</tr>
<tr>
<td>Nombre</td>
<td><input type="text" name="nombre" value='<?= $nombre ?>'></td>
</tr>
<tr>
<td>apellido</td>
<td><input type="text" name="apellido" value='<?= $apellido?>'></td>
</tr>
<tr>
<td>direccion</td>
<td><input type="text" name="direccion" value='<?= $direccion?>'></td>
</tr>
<tr>
<td valign="top">telefono</td>
<td>
<input type="text" name="telefono" value='<?= $telefono ?>'>
</td>
</tr>
</table>
<input type="submit" value="Aceptar">
</form>
Por ultimo creo la sentencia de update...

Código PHP:

include ('conexion.php');
echo 
'<p>';
echo 
'actualiza usuario';
echo 
'<p>';

    
$sql"uptdate datos from Nombre ='$nombre' , Apellido ='$apellido', Direccion ='$direccion' , Telefono ='$telefono' ,
     where Id =$id "
;
    
        
mysql_query($sql);
    
    if ( 
$sql == flase ){
    echo 
"salio algo mal ";
    }
    
?> 
en pocas palabras, cuando cliqueo un usuario no logro que pase la variable ID para que luego pueda modificarlo...
agredacere su ayuda



GRACIAS

DAnte

Última edición por Fogox; 15/06/2008 a las 15:44