Chess program in PHP code
<html>
<body>
<form action="" method="POST">
Enter numbers of boxes: <input type="textbox" name="r"><br><br>
<input type="submit" value="Generate" name="submit">
</form>
</body>
<?php
if($_POST['submit'])
{
$row=$_REQUEST['r'];
$col=$_REQUEST['r'];
echo "<table border='2' width='30%' height='60%'>";
for($i=1;$i<=$row;$i++)
{
echo "<tr>";
for($j=1;$j<=$col;$j++)
{
if($i%2!=0)
{
if($j%2==0)
echo "<td bgcolor='black'></td>";
else
echo "<td bgcolor='white'></td>";
}
else if($i%2==0)
{
if($j%2!=0)
echo "<td bgcolor='black'></td>";
else
echo "<td bgcolor='white'></td>";
}
}
echo "</tr>";
}
}
?>
</html>
:skin
:include name='super.defaultAdUnit'/>
Comments
Post a Comment