Write a program to create Chess board in PHP using for loop
Description:
Write a PHP program using nested for loop that creates a chess board.
Conditions:
- You can use html table having width=”400px” and take “30px” as cell height and width for check boxes.
View Solution/Program
<table width="400px" cellspacing="0px" cellpadding="0px" border="1px">
<?php
for($row=1;$row<=8;$row++)
{
echo "<tr>";
for($column=1;$column<=8;$column++)
{
$total=$row+$column;
if($total%2==0)
{
echo "<td height=35px width=30px bgcolor=#FFFFFF></td>";
}
else
{
echo "<td height=35px width=30px bgcolor=#000000></td>";
}
}
echo "</tr>";
}
?>
</table>
Tutorials Class - Output Window
Learn more about the similar topics:
Tutorials |
---|
PHP Loops |
Interview Questions & Answers |
---|
No Content Found. |