Categories:
Partners


Using the <table> tag to handle Tabular Data Control

For ASCII databases that contain quite a lot of data or changes often, updating the corresponding HTML on your page to display it isn't practical. For example, for a database with 30 rows, that means having to include 30 lines of HTML block (ie: span) on your page to accommodate this. Fortunately, there is another way that is more versatile when needed- the <TABLE> tag.

Consider a simple example where we store the name, age and sex of 6 persons in a text file. Now, we want to extract this data and display it on the web page in a tabular form.

The text file looks like this :

data2.txt:

name|age|sex
~Premshree Pillai~|~19~|~male~
~Vinod~|~18~|~male~
~Usha~|~19~|~female~
~John~|~25~|~male~
~Jimmy~|~17~|~male~
~Andrew~|~39~|~male~
By using the <TABLE> tag, we can display this data by merely using a skeleton HTML block:

Corresponding HTML page:
<OBJECT ID="data2" CLASSID="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
	<PARAM NAME="DataURL" VALUE="data2.txt">
	<PARAM NAME="UseHeader" VALUE="TRUE">
	<PARAM NAME="TextQualifier" VALUE="~">
	<PARAM NAME="FieldDelim" VALUE="|">
</OBJECT>

<TABLE DATASRC="#data2" BORDER="2">
<THEAD>
	<TH>Name :</TH>
	<TH>Age :</TH>
	<TH>Sex :</TH>
</THEAD>
<TR>
	<TD><SPAN DATAFLD="name"></SPAN></TD>
	<TD><SPAN DATAFLD="age"></SPAN></TD>
	<TD><SPAN DATAFLD="sex"></SPAN></TD>
</TR>
</TABLE>
The output will look like this :
Name : Age : Sex :
Premshree Pillai 19 male
Vinod 18 male
Usha 19 female
John 25 male
Jimmy 17 male
Andrew 39 male

Notice how we added the DATASRC attribute above- only once into the <TABLE> tag itself, and not every single tag that will display a data field. The three table columns (TDs) of the table will each hold the information for the specified database column, denoted using the DATAFLD attribute. IE will automatically generate the corresponding HTML codes to display and separate each data inside the columns. Cool!