Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/10/2011, 13:20
Avatar de CesarHC
CesarHC
 
Fecha de Ingreso: junio-2011
Ubicación: localhost
Mensajes: 566
Antigüedad: 12 años, 11 meses
Puntos: 56
Pregunta Selecionar una fila de una lista de datos.

Hola a todos otra vez molestando XD,estoy haciendo unas pruebas y tengo el siguiente problema, tengo este codigo que me muesta una lista de datos con un boton llamado seleccionar al lado de cada fila,lo que quiero hacer es mandar los datos da la fila que seleccione a los inputs del formulario y luego modificarlos, lo que necesito saber es solo como mandar los datos de una fila especifica a los campos del formulario, me orientan un poco? Gracias.

Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Ejemplo</title>
  5. </head>
  6.            
  7. <body onload="showFlatCalendar()" bgcolor="#F9F9F9">
  8. </div>
  9. <form action="frmprueba.php" method="post" enctype="multipart/form-data" name="formulario">  
  10. <h1 align="center" class="titulo">PRUEBA</h1>
  11. <table  align="center" id="datos" >
  12. <tr>
  13.     <th></th>
  14.     <td><input name="idprueba" type="hidden" size="430" value="<?php $idprueba ?>" > </td>
  15.   </tr>
  16.   <tr>
  17.     <th>Nombre</th>
  18.     <td><input type="text" id="nombre"  size="30" name="nombre" value="<?php $nombre?>"/></td>  
  19.   </tr>
  20.   <tr>
  21.     <th>Apellido</th>
  22.     <td><input type="text" id="apellido"  size="30" name="apellido" value="<?php $apellido?>"/></td>  
  23.   </tr>
  24.     <td colspan="2" align="center"><input name="submit" type="submit" value="Modificar" id="button"></td>
  25.     </tr></table>
  26.  
  27. </form>
  28.  
  29. <?php
  30.  
  31. $link = mysql_connect("localhost", "root","");
  32. mysql_select_db("reqcot", $link);  
  33. $result = mysql_query("SELECT idprueba ,nombre, apellido FROM prueba ORDER BY idprueba DESC LIMIT 5; ", $link);
  34. if ($row = mysql_fetch_array($result)){
  35.  
  36.    echo "<table width='200' border='1' align='center'>
  37.    <td align='center'>Nombre</td>
  38.    <td align='center'>Apellido</td>
  39.     <td align='center' >Accion</td> \n";
  40.    
  41.    do {
  42.       echo "
  43.  <tr>
  44.    <td align='center'>".$row["nombre"]."</td>
  45.    <td align='center'>".$row["apellido"]."</td>
  46.     <td align='center'><input type='submit' name='selecionar' value='Seleccionar'  
  47.      id='button'></td>
  48.  </tr>
  49.       ";
  50.    } while ($row = mysql_fetch_array($result));
  51.    echo "</table> \n";
  52. } else {
  53. echo "¡ No se ha encontrado ningún registro !";
  54. }
  55. ?>
  56.  
  57. </body>
  58. </html>
__________________
Solo la práctica no te traicionara ¡¡¡¡¡¡

Seguir el camino tu debes PHP The Right Way.