Riju18

no.84_chessboard_with_loop

Feb 7th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="UTF-8">
  5.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.   <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7.   <title>chessboard</title>
  8.   <style media="screen">
  9.     table,th,td{
  10.       margin: 50px auto;
  11.       border: 1px solid black;
  12.       border-collapse: collapse;
  13.       padding: 10px;
  14.     }
  15.   </style>
  16. </head>
  17. <body>
  18.   <table>
  19.     <?php
  20.       for ($row=0; $row < 8; $row++) {
  21.         echo "<tr>";
  22.         for ($colum=0; $colum < 8; $colum++) {
  23.           $total = $row+$colum;
  24.           if ( $total % 2 == 0) {         //checking even column;
  25.             echo "<td style='background-color:black;'></td>";
  26.           }
  27.           else {
  28.             echo "<td style='background-color:gray;'></td>";
  29.           }
  30.         }
  31.       }
  32.      ?>
  33.   </table>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment