Bullschmidt.com
Home
Web Database Concept
How We Work Together
Bio
Web Database Sample
Classic ASP Design Tips
Bar Chart Tool
Web Design Resources
Access Database Sample
Classic ASP Design Tips
Multiple Records in Each Row
These are opinions of J. Paul Schmidt, MBA.
No warranties are either expressed or implied.
To Use Paul's Services:
Paul@Bullschmidt.com
Here is a way to get a recordset to display multiple records (in this case 3) in each row to look something like this:
Anderson, Bill
Bentson, James
Carlson, Andrew
Enders, Jack
Franklin, Tim
Gant, Carl
Higgins, Ed
Jackson, Frank
Landers, John
Before the recordset loop:
<% ' Initialize. %>
<% intCol = 0 %>
<% ' Start table. %>
<table border="1" width="100%">
Within the recordset loop:
<% ' If first col, start row. %>
<% If intCol = 0 Then %>
<tr>
<% End If %>
<% ' Show data in its own td. %>
<td width="33%">
<%= objRS("LName") %>, <%= objRS("FName") %>
</td>
<% ' If final col, end row. %>
<% If intCol = 2 Then %>
</tr>
<% End If %>
<%
If intCol = 2 Then
intCol = 0
Else
intCol = intCol + 1
End If
%>
And after the recordset loop:
<%
' Undo the previous intCol increment:
If intCol = 0 Then
intCol = 2
Else
intCol = intCol - 1
End If
%>
<% ' If first col, add 2 more cols and end row. %>
<% If intCol = 0 Then %>
<td> </td>
<td> </td>
</tr>
<% End If %>
<% ' If second col, add 1 more col and end row. %>
<% If intCol = 1 Then %>
<td> </td>
</tr>
<% End If %>
<% ' End table. %>
</table>
To Use Paul's Services:
Paul@Bullschmidt.com
Copyright © 2000-2010
J. Paul Schmidt, MBA
Freelance Web and Database Developer
All Rights Reserved
Privacy Policy