Ver Mensaje Individual
  #4 (permalink)  
Antiguo 29/09/2010, 02:23
sergio9243
 
Fecha de Ingreso: septiembre-2010
Mensajes: 9
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: Leer Dato Tabla PHP, HTML y MySQL

Hola Deffer, gracias por contestar.

Es correcto lo que dices, pero mi principal problema es leer el dato que introducen en la tabla como leerlo. Te cuento. Producto y Existencia Actual me los da la BD, pero existencia real lo tienen que introducir desde la tabla en HTML. Como Leo ese dato y se lo resto a existencia actual y que automaticamente me lo ponga en diferencia. Te pongo el codigo de lo que tengo. Pero me imagino que tendré que usar una función en javascritp o algo aparte, pero no se como hacerlo de momento, pero sigo en ello. De momento no quiero actualizar nada de la BD, eso ya lo haré luego cuando primero logre hacer esto

Código PHP:
Ver original
  1. <table class="historial">
  2.   <thead><tr><th style="width: 250px;">Producto</th><th>Existencia Actual</th><th>Existencia Real</th><th>Diferencia</th></tr>
  3.   </thead>
  4.   <tbody>
  5. <?php
  6.  
  7. while ($fila = mysql_fetch_row($resultado)){
  8.   $string = $fila[1];
  9.  
  10.   if ($fila[5]!=0){
  11.     $consulta1 = "SELECT nombre FROM color WHERE idcolor =".$fila[5];
  12.     $resultado1 = mysql_query ($consulta1, $link);
  13.     $fila1 = mysql_fetch_row($resultado1);
  14.     $string = $string." - ".$fila1[0];
  15.   }
  16.  
  17.   if ($fila[3]!=0){
  18.     $consulta1 = "SELECT nombre FROM idioma WHERE ididioma =".$fila[3];
  19.     $resultado1 = mysql_query ($consulta1, $link);
  20.     $fila1 = mysql_fetch_row($resultado1);
  21.     $string = $string." - Idioma ".$fila1[0];
  22.   }
  23.  
  24.   if ($fila[4]!=0){
  25.     $consulta1 = "SELECT nombre FROM talla WHERE idtalla =".$fila[4];
  26.     $resultado1 = mysql_query ($consulta1, $link);
  27.     $fila1 = mysql_fetch_row($resultado1);
  28.     $string = $string." - Talla ".$fila1[0];
  29.   }
  30.  
  31. $consulta1 = "SELECT * FROM inventario WHERE idproducto=".$fila[0];
  32. $resultado1 = mysql_query($consulta1, $link);
  33. $fila1 = mysql_fetch_row($resultado1);
  34.  
  35. $tui = $fila1[3];
  36. if ($tui==''){$tui = 0;}
  37. $tue = $fila1[4];
  38. if ($tue==''){$tue = 0;}
  39. $tus = $fila1[5];
  40. if ($tus==''){$tus = 0;}
  41. $total = $tui + $tue - $tus;
  42.   ?>
  43.   <td> <?php echo $string;?></td>
  44.   <td><?php echo $total;?></td>
  45.  
  46.      <td>
  47.         <input  
  48.             style="width:75px; text-align: right;"
  49.             value=""
  50.             type="text"  
  51.             name=""
  52.             onchange = "">
  53.     </td>
  54.       <td>
  55.         <input  
  56.             style="width:75px; text-align: right;"
  57.             type="text" readonly="readonly"
  58.             value=""
  59.             name="">
  60.       </td>
  61.   <?php
  62.   printf("</tr>");
  63. }
  64. printf("</tbody></table>");