$tamany = 8; echo "<table border=1>"; for ($i = 0; $i < $tamany; $i++) { echo "<tr>"; for ($j = 0; $j < $tamany; $j++) { if (($i + $j) % 2 == 0) { echo "<td style='background-color:black;width:20px;height:20px'></td>"; } else { echo "<td style='width:20px;height:20px'></td>"; } } echo "</tr>"; } echo "</table>";