Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <!DOCTYPE html>
  2.      <html>
  3.      <head>
  4.   <title></title>
  5.   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6.   </head>
  7.   <body>
  8.   <h3>Chess Board using Nested For Loop</h3>
  9.    <table width="270px" cellspacing="0px" cellpadding="0px" border="1px">
  10.    <!-- cell 270px wide (8 columns x 60px) -->
  11.       <?php
  12.       for($row=1;$row<=8;$row++)
  13.       {
  14.           echo "<tr>";
  15.           for($col=1;$col<=8;$col++)
  16.           {
  17.           $total=$row+$col;
  18.           if($total%2==0)
  19.           {
  20.           echo "<td height=30px width=30px bgcolor=#FFFFFF></td>";
  21.           }
  22.           else
  23.           {
  24.           echo "<td height=30px width=30px bgcolor=#000000></td>";
  25.           }
  26.           }
  27.           echo "</tr>";
  28.     }
  29.           ?>
  30.   </table>
  31.   </body>
  32.   </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement