Color to rows in a table


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?
  2. if($bgcolor == '#FFFFFF')$bgcolor = '#F5F5F5';
  3. else $bgcolor = '#FFFFFF';
  4. ?>
  5.  
  6. ----
  7.  
  8. <?
  9. $vector = array("ar.gif", "cl.gif", "co.gif", "cr.gif", "do.gif", "es.gif", "mx.gif", "pe.gif", "ve.gif");
  10. $vector2 = array("Argentina", "Chile", "Colombia", "Costa Rica", "República Dominicana", "España", "Méjico", "Perú", "Venezuela");
  11. for($i=0;$i<count($vector);$i++){
  12. if($bgcolor == '#FFFFFF')$bgcolor = '#F5F5F5';
  13. else $bgcolor = '#FFFFFF';
  14. echo ' <tr>
  15. <td width="100%" bgcolor="'.$bgcolor.'"><img src="'.$vector[$i].'"> '.$vector2[$i].'</td>
  16. </tr>
  17. ';
  18. }
  19. ?>

URL: http://www.webtaller.com/construccion/lenguajes/php/lecciones/colorear-tablas-datos-en-php.php

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.