Ver Mensaje Individual
  #3 (permalink)  
Antiguo 11/12/2009, 13:43
ingross
 
Fecha de Ingreso: octubre-2009
Mensajes: 34
Antigüedad: 14 años, 6 meses
Puntos: 1
Respuesta: Intercalar color en tablas

Agradesco tu respuesta y el tiempo q te tomaste .
Pero ingreso el codigo que pones y no sale el color :(

podrias orientarme?

Código PHP:
Ver original
  1. <?php
  2.              require 'conexion.php';
  3.             $link=conecta();
  4.            
  5.            
  6.             $db_seleccionada =bd();
  7.             $sql="select numero,clave,clave_con,conceptos,unidades,cantidad,costo_unitario, importe, c_sem1, i_sem1,c_est1,i_est1 ,a_sem from obracivil " ;
  8.             $datos=mysql_query($sql,$link) or die ("Error en sintaxis de sql");
  9.            
  10.             echo "<table border='0' bordercolor = '#FFFFFF'>\n";
  11. echo "<TH bgcolor='#3399FF'>Consecutivo</TH><TH bgcolor='#3399FF'>Código concepto</TH><TH bgcolor='#3399FF'>Concepto</TH><TH bgcolor='#3399FF'>Unidad</TH><TH bgcolor='#3399FF'>Presupuesto origen cantidad</TH><TH bgcolor='#3399FF'>Costo unitario</TH><TH bgcolor='#3399FF'>Presupuesto origen importe</TH><TH bgcolor='#9999FF'>Esta estimación cantidad</TH><TH bgcolor='#9999FF'>Esta estimación importe</TH><TH bgcolor='#009933'>Acumulado estimado cantidad</TH><TH bgcolor='#009933'>Acumulado estimado importe</TH><TH bgcolor='#FF0000'>Por estimar cantidad</TH><TH bgcolor='#FF0000'>Por estimar importe</TH>";
  12.            
  13.            
  14.             $i=0;
  15.  
  16. while($reg=mysql_fetch_array($datos)){
  17.  
  18.      
  19.            if($i==0){        
  20.           echo "<tr bgcolor='#cccccc'>";      
  21.  
  22.          }else{
  23.  
  24.             echo "<tr bgcolor='#FFFFFF'>";
  25.          }             
  26.                
  27.     echo "<tr>";
  28. $costo_unitario=number_format($reg['costo_unitario'],2);
  29. $importe=number_format($reg['importe'],2);
  30. $c_sem1=number_format($reg['c_sem1'],2);
  31. $i_sem1=number_format($reg['i_sem1'],2);
  32.  
  33. $c_est1=number_format($reg['c_est1'],2);
  34. $i_est1=number_format($reg['i_est1'],2);
  35. //echo "<td width=60 align=right >&nbsp;".$reg["a_sem"]."</td>";               
  36. echo "<td width=60 align=right >&nbsp;".$reg["numero"]."</td>";
  37. echo "<td width=10 align=left >&nbsp;".$reg["clave_con"]."</td>";
  38. echo "<td width=550 align=left >&nbsp;".$reg["conceptos"]."</td>";
  39. echo "<td width=60 align=CENTER >&nbsp;".$reg["unidades"]."</td>";
  40. echo "<td width=80 align=right >&nbsp;".$reg["cantidad"]."</td>";
  41. echo "<td width=80 align=right >\$$costo_unitario</td>";
  42. echo "<td width=80 align=right >\$$importe</td>";
  43. //captura de datos reales
  44. echo "<td width=80 align=right >\$$c_sem1</td>";
  45. echo "<td width=80 align=right >\$$i_sem1</td>";
  46.  
  47. // acumulado estimado sem0 +sem1
  48. echo "<td width=80 align=right >\$$c_sem1</td>";
  49. echo "<td width=80 align=right >\$$i_sem1</td>";
  50. // acumulado estimado c_sem-cantidad origen
  51.  
  52. echo "<td width=80 align=right >\$$c_est1</td>";
  53. echo "<td width=80 align=right >\$$i_est1</td>";
  54.  
  55.  
  56.  
  57.  
  58.                    
  59.  
  60. }
  61.            
  62.             echo "</table>";
  63.             mysql_free_result($datos);
  64.             mysql_close($link);
  65.  
  66.  ?>