When you query a database, the result you receive is a recordset. The form in which your result can be presented is affected by the capabilities of the language you use. This can present a challenge for certain languages. This article presents one way to meet that challenge if you program for the web.
Using the HTML Table Element as a Recordset (Page 1 of 5 )
Recordset is a name given to the result of a database query. There are other names for it, such as resultSet. This result is in the memory of the client’s computer. For a language like C++, there are APIs, which link the database program (code to manipulate the data) to the database engine. These APIs have (produce) the recordset, which is accessed by the programming language (C++).
But what about the HTML TABLE element? The HTML TABLE element has the properties and methods that classical recordsets have. The cell data is the content of a table cell. But the HTML table and its content, by default, appears on the browser page, while the content of a classical recordset does not appear on the client’s document window! If you give the HTML Table the style property, display:none, it will not appear or occupy space on the browser’s window.
Seen as a recordset, the field data of a row of the TABLE element is the content of the TD element. This can be anything; it can be text, image, video or even sound. Other recordsets do not easily take (accept) non-text objects. Clearly, the HTML TABLE element can be used as a recordset.
The HTML TABLE element as a recordset has the following advantages over classical recordsets:
It does not have to be only two-dimensional; it can be three- or even four-dimensional. When it comes to dimensions, you can make it as complex as you want. However, I will not address the two-dimensional case.
For those of you who are not used to handling recordsets by hand, know that any good container can be used as a resultset. The C++ vector container, for example, can be used as a recordset in the C++ world. The HTML TABLE element is a container. It might not look like one, but it is.
If you are dealing with the Internet and you have a basic (or small) database program to write, you have a couple of choices.
You can use HTML in place of a studio, for flexibility, and in place of the Windows API for ease of work.
This is an aspect of web development. I will handle the case of large databases in a different series.