How to SELECT cells from mysql for a HTML table?
MySql has no XML data type so it's hardly can help ( more help then app layer code) to generate HTML markup.
It can help to create ordered stream of cells. Kind of

select r.row_number, h.column_number, c.content
from table_cells c 
join table_rows r on c.row_id = r.row_d
join table_cols h on c.column_id = h.column_id
order by r.row_number, h.column_number


Or may be to convet sparse array of cells to regular one as directed by table_cols and table_rows, if that is the case.