Spider Web Woman Designs
 

Multi-Column HTML Table Results from a Single Database Column

Sample

You can display a single database column horizontally across a multi-column HTML table using the FrontPage Database Results Wizard (DRW). For example, here is a 3-column HTML table displaying results from an 11 record database containing U.S. State abbreviations;
MS MO MT
NE NV NH
NJ NM NY
NC ND

Normally, the DRW would display this as a single column table with 11 rows. The multi-column display is accomplished by adding some ASP script to suppress the </tr><tr> tags between records. 

Implementation

The first step is to use the DRW to create a one column table with no header. The DRW results will look like this;

This is the start of the Database Results region.
<<State>>
This is the end of the Database Results region.

Then, in HTML view, locate the table cell and row tags (illustrated by the Before column in the table below) and replace them with the script (illustrated by the After column in the table below);

Before After
<tr>
<td>
<%
count = count + 1
If count = 1 Then
%>
<tr>
<%
End If
%>
<td>
.
.
.
Before After
</td>
</tr>
</td>
<%
If count = 3 Then
count = 0
%>
</tr>
<%
End If
%>
.
.
.
Before After
</tbody> <%If count <> 0 Then Response.Write "</tr>"%>
</tbody>

You can change the number of columns in the HTML table by changing the 3 in the line, If count = 3 Then, to another value. For example, If count = 5 Then would create a five column HTML table.

© Copyright 2002 Stephen C. Travis, all rights reserved. Republished with the permission of the author.

Back to Stephen Travis' Thingumajig