Your Ad Here

Posted By

Piotrek290 on 11/21/09


Tagged

css php table chess


Versions (?)

chess table


 / Published in: PHP
 

  1. <?
  2. $start_x = 0;
  3. $start_y = 0;
  4.  
  5. $end_x = 8;
  6. $end_y = 8;
  7.  
  8. $margin = array(10,10);
  9.  
  10. for($c1=$start_x; $c1<$end_x; ++$c1){
  11. for($c2=$start_y; $c2<$end_y; ++$c2){
  12. $col = ($c1%2==0)?(($c2%2==0)?'#5A4E38':'#B29F7A'):(($c2%2==0)?'#B29F7A':'#5A4E38');
  13.  
  14. echo '<div style="position:absolute;left:'.($c1*20+$margin[0]).'px;top:'.($c2*20+$margin[1]).'px;padding:10px;background:'.$col.';"></div>'."\n";
  15. }
  16. }
  17.  
  18. echo '<div style="position:absolute;top:200px;left:10px;">'.$c1*$c2.'</div>';
  19. ?>

Report this snippet  

You need to login to post a comment.