You really should study up on HTML tables.
The table code you provided will just make an ugly table.
If you want tables to have different numbers of cells per row, you'll have to adjust the colspans, etc.
Why don't you first actually lay out the HTML table content for the data as you have provided it, and we'll help you figure out how to automate the process of loading content from the database.
Include your database structure in your answer.