A query result contains a set of items that should be displayed as a structured list.
Write the list items within the proper HTML tags for the desired type of list.
More structured than paragraphs and less structured than tables, lists provide a useful way to display a set of individual items. HTML provides several styles of lists, such as ordered lists, unordered lists, and definition lists. You may also wish to nest lists, which requires list-within-list formatting.
Lists generally consist of an opening and closing tag that surround a set of items, each of which is delimited by its own tags. List items correspond naturally to rows returned from a query, so generating an HTML list structure from within a program is a matter of encoding your query result, surrounding each row with the proper item tags, and adding the opening and closing list tags. Two approaches to list generation are common. If you want to print the tags as you process the result set, do this:
Print the list opening tag.
Fetch and print each result set row as a list item, including the item tags.
Print the list closing tag.
Alternatively, you can process the list in memory:
Store the list items in an array.
Pass the array to a list generation function that adds the appropriate tags, then print the result.
The examples that follow demonstrate both approaches.
An ordered list consists of items that have a particular sequence. Browsers typically display ...