Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/08/2012, 14:42
Avatar de totti026
totti026
 
Fecha de Ingreso: junio-2011
Mensajes: 150
Antigüedad: 12 años, 10 meses
Puntos: 4
Pregunta generar input's text por cada registro dentro de un while

Hola que tal,
tengo esta consulta que me va imprimiendo el mes con su importe... pero ahora quiero meterle un campo(input text) a cada registro para depues guardarlos de nuevo..
Código PHP:
Ver original
  1. <?php
  2. $meses[1]='ENERO';
  3. $meses[2]='FEBRERO';
  4. $meses[3]='MARZO';
  5. $meses[4]='ABRIL';
  6. $meses[5]='MAYO';
  7. $meses[6]='JUNIO';
  8. $meses[7]='JULIO';
  9. $meses[8]='AGOSTO';
  10. $meses[9]='SEPTIEMBRE';
  11. $meses[10]='OCTUBRE';
  12. $meses[11]='NOVIEMBRE';
  13. $meses[12]='DICIEMBRE';
  14. $sql="SELECT YEAR(fecha) AS ANIO, MONTH(fecha) AS MES, MONTHNAME(fecha) AS NOMBRE, importe, SUM(iva) as tiva, SUM(importe) as timp FROM tabla WHERE YEAR(fecha)='$anio' AND importe!='0' AND iva!='0' GROUP BY ANIO DESC , MES ASC";$fechas=mysql_query($sql,$conexion);
  15.  
  16. echo "<form name='form' id='form' action='' method='post'>";
  17. echo "<table>";
  18. echo "<thead>";
  19. echo "<tr>";
  20. echo "<th>MES</th>";
  21. echo "<th>OBSERVACIONES</th>";
  22. echo "<th>IMPORTE</th>";
  23. echo "</tr>";
  24. echo "</thead>";
  25. $totalimp = 0;
  26. while ($fech=mysql_fetch_array($fechas))
  27. {
  28. $timporte=$fech['tiva']+$fech['timp'];
  29. echo "<tr>";
  30. echo "<td>".$meses[$fech['MES']]."</td>";
  31. echo '<td style="text-align:center"><input type="text" name="'.$meses[$fech['MES']].'observacion" id="'.$meses[$fech['MES']].'observacion" size="80"></td>';
  32. echo "<td style='text-align:right'>$timporte<input name='mes' type='checkbox'></td></tr>";
  33. $totalimp+=$timporte;
  34. }
  35. echo "<tr><td></td><td>TOTAL</td><td>$$totalimp</td></tr></table>";
  36. }
  37. ?>

esto me genera algo asi:


donde en el codigo cada input text tendria algo asi como nombre:

Código HTML:
Ver original
  1. name="ENEROobservacion"

y a la hora de recibir la variable nombre de cada input (name="'.$meses[$fech['MES']].'observacion") con POST ya no se como hacerle...
Código PHP:
Ver original
  1. $observaciones=$_POST[''];