Forum Moderators: open
<table border="0" cellpadding="0" cellspacing="0" width="780" id="table1">
<tr>
<% ' cycle through the record set and display each row results
do until objRS.EOF %>
<td><%= objRS ("County")%>, </td>
<% ' increment record position with MoveNext method
objRS.MoveNext
<!-- next row=next record -->
loop
%>
</tr>
</table>
How can i do this?
you can set a fixed number of columns per <tr> and count the columns so that if you reach the limit, then you would start a new <tr>.
I handle this many times - lists of data in three columns. I take a RecordCount of the number of returned entries, divide by 3 (or 5 if it's a 5 column table) and run a loop up to that number, with the MoveNext() inside each <td>. After each data I use <br> to go to the next line.
Hope that makes sense. I can post some code if you want but i'd have to clean up quite a bit of extra stuff in there first.
first I run the query to get my data, then I get the number of records and set variables for my column record numbers (forgive my goofy variable names):
var numstu = rsGaveForm.RecordCount;
var sally = Math.round(numstu/3);
var betty = sally * 2;
then, down where the columns start it looks like this (lots stripped out for clarity)
the first column goes from record count 0 to "sally"
<tr>
<td>
<% if (rsGaveForm.EOF) { %>
<% } else { %>
<% for (var i=0; i < sally ; i++) { %>
<%=rsGaveForm("name")%> <br>
<% rsGaveForm.MoveNext();
if (rsGaveForm.EOF){break} %>
<% } %><% } %>
</td>
the second column goes from sally to betty
<td>
<% if (rsGaveForm.EOF) { %>
<% } else { %>
<% for (var i=sally ; i < betty ; i++) { %>
<%=rsGaveForm("name")%><br>
<% rsGaveForm.MoveNext();
if (rsGaveForm.EOF){break} %>
<% } %><% } %>
</td>
and finally the third column goes from betty to numstu
<td>
<% if (rsGaveForm.EOF) { %>
<% } else { %>
<% for (var i=betty ; i < numstu ; i++) { %>
<%=rsGaveForm("name")%><br>
<% rsGaveForm.MoveNext();
if (rsGaveForm.EOF){break} %>
<% } %>
<% } %>
If you need five columns I do it a bit diferently and code left to right rather than in columns, doing a bunch of that same code in each column, but also checking for the record number, and if a multiple of 5 I start a new <tr>
a bit complicated.
I left in the bit about checking first for EOF on each column just as a reminder.
Hope that mess is clear.