SDD Topic has been refreshed!
The table element us used to display and format data in a tabular format.
It is very useful for displaying data from database results.
The table elements you will be expected to manipulate are:
<table>
<th>
<tr>
<td>
When writing a table in HTML you can follow the following logic:
You use the <table> tag to open a table element
Then you can have headings using the <th> which by default are formatted as bold and centre aligned.
You then need to create a new row using the <tr> tag
Then for each row you would create as many cells using the table data tags <td> and </td> as needed
You would then close the row using </tr>
Repeat steps 3-5 as many times as needed
Then close the table element using </table>
When using this in a PHP file to show results you would create the table element once you have established you have a result. And then each row returned would be displayed in within a new <tr> element with each piece of data within a new cell <td>.
An example is shown below:
You can apply various style rules to tables such as shading, alternating row colours etc. Some further information can be found here.
The page https://divtable.com/table-styler/ offers a generator which can be used to style a table and provide the appropriate CSS rules.