simplest Posted January 2, 2019 Share Posted January 2, 2019 (edited) I can do a simple for loops to create a N x N table. However I am not sure how to approach for tables with different colspan in different cells like this?... Any hints or tips on how I should proceed? Thanks in advance. Edit: This is the furthest I can come up with but there is something wrong in it and I am not sure what it is... <html> <style> table { border-collapse: collapse; width: 900px; } th, td { border: 1px solid black; } </style> <?php echo "<table><tr> <td rowspan=\"2\">ID</td> <td rowspan=\"2\">Name</td> <td rowspan=\"2\">Date</td>"; for ($i = 1; $i <= 31; $i++) { echo "<td colspan=\"3\">$i</td>"; } echo "</tr>"; for ($row = 1; $row <=5; $row++) { for ($col = 1; $col <=96; $col++) { echo "<td>" . $col . "</td>"; } echo "</tr>"; } echo "</tr></table>"; ?> </html> Edited January 2, 2019 by simplest Link to comment Share on other sites More sharing options...
justsomeguy Posted January 2, 2019 Share Posted January 2, 2019 I see one opening <tr> tag and 3 closing </tr> tags, so the first step is probably to figure out when you need to start a new row. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now