You want to display a query result as an HTML table.
Use each row of the result as a table row. If you want an initial row of column labels, either supply your own, or use the query metadata to obtain the names of the columns in the query result.
HTML tables are useful for presenting highly structured output. One reason they’re popular for displaying the results of queries is that they consist of rows and columns, so there’s a natural conceptual correspondence between HTML tables and database tables or query results. In addition, you can obtain column headers for the table by accessing the query metadata. The basic structure of an HTML table is as follows:
The table begins and ends with
</table> tags and encloses a set of rows.
Each row begins and ends with
</tr> tags and encloses a set of cells.
Tags for data cells are
</td>. Tags for header cells are
(Typically, browsers display header cells using boldface or other
Tags may include attributes. For example, to put a border around each
cell, add a
border="1" attribute to the
<table> tag. To right-justify a table cell,
align="right" attribute to the
Note that you should always supply the closing tag for each table element. This is a good idea in general for any HTML element, but especially so for tables. If you omit closing tags, some browsers will supply them automatically, but others may lock up ...