I made a script where it creates a pyramid using a php for loop and html table elements, but the pyramid isn’t how I want it yet. The code:
<?php echo "<table width=400px"; echo "<tr>"; //Inner Loop for ($x = 0; $x <= 8; $x++) { //Outer loop for ($z = 1; $z <= $x; $z++) { echo "<td height=50px width=50px bgcolor=black></td>"; } echo "n"; echo "</tr>"; } echo "</table>"; ?>
But I want it to look like this:
Can someone help me with that?
Advertisement
Answer
Simply add cellspacing=0 to table
<?php echo "<table cellspacing=0 width=400px"; echo "<tr>"; //Inner Loop for ($x = 0; $x <= 8; $x++) { //Outer loop for ($z = 1; $z <= $x; $z++) { echo "<td height=50px width=50px bgcolor=black></td>"; } echo "n"; echo "</tr>"; } echo "</table>"; ?>