Display Your Recordset Sideways

Display your recordsets sideways! Instead of displaying recordsets on your page one, then a line break, then another one, etc, why not display your records in a fashion that will more effectively use your available screen space? Horizontally!

In this example, we will demonstrate how to show an html table of records retrieved, and show those records three(3) cells across, per row.

For demonstration purposes only! Please be aware of SQL Injection, and techniques to avoid.
<%@ LANGUAGE = "VBScript" %>
 
<%
 Set cnDZ = Server.CreateObject("ADODB.Connection")
 cnDZ.Open "DSN=yourDSNhere"
 %>
 <html><body>
 <%
 Set rs = cnDZ.Execute("SELECT * FROM TABLE")
    Not rs.EOF Then
         Response.Write"<table border=1>"
         LinkCount = 0
         Do Until rs.EOF
         'change this 3 to any number you like:
    LinkCount Mod 3 = 0 Then
    LinkCount <> 0 Then Response.Write"</tr>"
         Response.Write"<tr><td>"&rs("NAME")&"<br>"&rs("DESCRIP")&"</td>"
    
        Response.Write"<td>"&rs("NAME")&"<br>"&rs("DESCRIP")&"</td>"
    If
         LinkCount = LinkCount + 1
         rs.MoveNext
         Loop
     Response.Write"</tr></table>"
     rs.Close
 Set rs = Nothing
    Response.Write"Sorry, no records were found!"
 End If
 %>
 </body></html>
 <%
 cnDZ.Close
 Set cnDZ = Nothing
 %>
For a working example, see The Name Game

recordsets recorsets in columns access


Back To Top
© 1998 - 2024 psacake.com
Version 7.21 | Advertise on this site