Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/01/2013, 18:49
desoler
 
Fecha de Ingreso: agosto-2008
Ubicación: Miami, FL
Mensajes: 210
Antigüedad: 15 años, 8 meses
Puntos: 2
Pregunta solo actualiza el ultimo registro

Hola gente, a ver si me pueden echar una mano por que ya no le encuentro mas vueltas.

hago una consulta a la base de datos y listo los resultados. Lo logico seria que para actualizar los datos abriera un formulario cargando estos datos, pero lo hago en el mismo paso.
Todo funciona bien, pero solo me actualiza el ultimo registro y no los anteriores.
A ver si alguien puede echarme una mano, ya he buscado y releído pero no lo puedo solucionar.

Código PHP:
Ver original
  1. //1. Crear conexión a la Base de Datos
  2. $conexion = mysql_connect("host","user","pass");
  3. if (!$conexion) {
  4. die("Fallo la conexión a la Base de Datos: " . mysql_error());
  5. }
  6. //2. Seleccionar la Base de Datos a utilizar
  7. $seleccionar_bd = mysql_select_db("db", $conexion);
  8. if (!$seleccionar_bd) {
  9. die("Fallo la selección de la Base de Datos: " . mysql_error());
  10. }
  11.  
  12.  
  13. $seleccionar = mysql_query("SELECT * FROM playing_today");
  14. if (!$seleccionar) {
  15. die("Fallo en la seleccion de registro en la Base de Datos: " . mysql_error());
  16. }        
  17.  
  18. echo"
  19. <form action='actualizar_player_price.php' method='POST'>
  20.  <table border=0 id=mytable cellspacing=0>
  21.    <tr class='spec'>
  22.      <th align=center width='20'>ID</th>
  23.      <th align=center>Player Name</th>
  24.      <th class='title'>Prev. Owed</th>
  25.      <th class='title'>Court Rental</th>
  26.      <th class='title'>Pala Rental</th>
  27.      <th class='title'>Beberage</th>
  28.      <th class='title'>Lesson</th>
  29.      <th class='title'>Pala Sale</th>
  30.      <th class='title'>Balls</th>
  31.      <th class='title'>Overgrip</th>
  32.      <th class='title'>Food</th>
  33.      <th class='title'>Other</th>
  34.      <th class='title'>Total</th>
  35.      <th class='title2'>Paid</th>
  36.      <th class='title2'>Curr. Owed</th>
  37.      <th class='title2'>Update</th>
  38.      <th class='title2'>Close</th>
  39.    </tr>
  40.  
  41. ";
  42.  
  43.  while ($fila = mysql_fetch_array($seleccionar))
  44.       {  
  45.  
  46.       $po = $fila['prev_owed'];
  47.       $ct = $fila['court_price'];
  48.       $pr = $fila['pala_rental_price'];
  49.       $bb = $fila['beberage_price'];
  50.       $le = $fila['lesson_price'];
  51.       $ps = $fila['pala_sale_price'];
  52.       $ba = $fila['balls_price'];
  53.       $og = $fila['overgrip_price'];
  54.       $fo = $fila['food_price'];
  55.       $ot = $fila['other'];
  56.       $pd = $fila['paid'];
  57.       $rt = $fila['rest'];
  58.  
  59.       $suma = $ct+$pr+$bb+$le+$ps+$ba+$og+$fo+$ot;
  60.       $rest = $suma-$pd;
  61.       $final = $rest+$po;
  62.  
  63. echo"
  64.  <tr class='spec' >
  65.    <td align=center width='20'>".$fila['personalID']."</td>
  66.    <td align=center width='170'>".$fila['first_name']." ".$fila['last_name']."</td>
  67.    <td align=center width='20'>".$fila['prev_owed']."</td>
  68.    <td align=center width='20'><input type='text' name='court_price' value='".$fila['court_price']."' size=5 /></td>
  69.    <td align=center width='20'><input type='text' name='pala_rental_price' value='".$fila['pala_rental_price']."' size=5 /></td>
  70.    <td align=center width='20'><input type='text' name='beberage_price' value='".$fila['beberage_price']."' size=5 /></td>
  71.    <td align=center width='20'><input type='text' name='lesson_price' value='".$fila['lesson_price']."' size=5 /></td>
  72.    <td align=center width='20'><input type='text' name='pala_sale_price' value='".$fila['pala_sale_price']."' size=5 /></td>
  73.    <td align=center width='20'><input type='text' name='balls_price' value='".$fila['balls_price']."' size=5 /></td>
  74.    <td align=center width='20'><input type='text' name='overgrip_price' value='".$fila['overgrip_price']."' size=5 /></td>
  75.    <td align=center width='20'><input type='text' name='food_price' value='".$fila['food_price']."' size=5 /></td>
  76.    <td align=center width='20'><input type='text' name='other' value='".$fila['other']."' size=5 /></td>";
  77.     echo "  
  78.    <td align=center width='20'>";echo " ".$suma." "; echo"
  79.    <td align=center width='20'><input type='text' name='paid' value='".$fila['paid']."' size=5 /></td>
  80.    <td align=center width='20'>";echo " ".$final." "; echo"</td>
  81.    <td align=center width='20'><input type='submit'></td>
  82.    <td align=center width='20'><a href='#'>Close</a></td>
  83.  </tr>
  84. ";
  85.  
  86. $_SESSION['personalID'] = $fila['personalID'];
  87. }
  88.  
  89. echo "</tabla></form>";
  90.  
  91. mysql_close($conexion);
__________________
Se invierte mas dinero en cirugía de pechos y viagra que en la cura del Alzheimer. En unos años tendremos viejas con grandes tetas y viejos con erecciones pero que no recordarán para que sirven..