Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/03/2012, 21:21
Avatar de el_cesar
el_cesar
 
Fecha de Ingreso: mayo-2001
Ubicación: Cali
Mensajes: 2.423
Antigüedad: 23 años
Puntos: 20
Mostrar array en tabla

Estoy recibiendo los datos que un formulario me envia en un array de esta forma:

Código PHP:
Ver original
  1. echo "<td><input type='text' name='cantidad[]' size='4' maxlength='3'  value='1'></td>";

Cuando los recibo los recibo asi

$cant = array($_POST['cantidad']);

el punto es que estoy construyendo una tabla tambien una tabla a partir de una consulta que hago a la base de datos y es así:

Código PHP:
Ver original
  1. $sql = 'select * from modulos where id in('.implode(',',$mod).')';
  2. $rsql = mysql_query($sql) or die (mysql_query());
  3.  
  4. $tablahtml='';
  5. $tablahtml.="<table >";
  6. $tablahtml.="<tr ><td><div style='align:center; background-color:#FF8000; color: #fffff; font-weight: bold;'>M&oacute;dulo</div></td>";
  7. $tablahtml.="<td><div style='align:center; background-color:#FF8000; color: #fffff; font-weight: bold;'>Cantidad</div></td>";
  8. $tablahtml.="<td><div style='align:center; background-color:#FF8000; color: #fffff; font-weight: bold;'>Valor</div></td></tr>";
  9.  
  10. while ($row = mysql_fetch_array($rsql)) {
  11.  
  12.  
  13. $tablahtml.="<tr><td>$row[1]</td>";
  14. $valor = $row[2] * $vr_hora;
  15.  
  16. //armamos el array para el total de horas
  17. $horasd[] = $row[2];
  18. $totalhoras = array_sum($horasd);
  19.  
  20. //convertimos valor a miles
  21.  
  22. $valor1_mil=number_format($valor,0,'.',',');
  23. //Armamos el array para sumar el valor total
  24.  
  25.  
  26. $precio[] = $row[2] * $vr_hora;
  27.  
  28. $tablahtml.="<td><div align='right'>$valor1_mil</div></td></tr>";
  29. }
  30. $inversion = array_sum($precio);
  31. $invmil = number_format($inversion,0,'.',',');
  32.  
  33. //calculamos los dias de desarrollo
  34.  
  35. if ($totalhoras < 8 ) {
  36. $as = 'horas';
  37. $hou = $totalhoras;
  38. }
  39. elseif($totalhoras > 30) {
  40. $messi = $totalhoras/30;
  41. $mesd = ceil($messi);
  42. $hou = $mesd;
  43. $as = 'meses';
  44.  
  45. }
  46. else {
  47. $as = 'dias h&aacute;biles';
  48. $hou = $totalhoras;
  49.  
  50. }
  51. $tablahtml.="<tr><td><div style='background-color: #FAAC58; font-weight: bold;'>Valor de la Inversi&oacute;n</td>";
  52. $tablahtml.="<td><div style='background-color: #FAAC58; font-weight: bold;'>$invmil</td>";
  53. $tablahtml.="<tr><td><div style='font-weight: bold;'>Tiempo de Desarrollo</td>";
  54. $tablahtml.="<td><div style='font-weight: bold;'>$hou $as</td>";
  55.  
  56. $tablahtml.="</table>";

El punto es que necesito que en la columna cantidad me salga el valor del array $cant segun corresponda, lo hice con print_r y no funciono, poniendo $cant y tampoco.

Alguna idea de como lograrlo?
__________________
Say no more.......