Print Page | Close Window

how to display data in 3 columns by 4 rows format

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=28671
Printed Date: 28 March 2026 at 9:10pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: how to display data in 3 columns by 4 rows format
Posted By: angkorboy
Subject: how to display data in 3 columns by 4 rows format
Date Posted: 28 June 2010 at 9:16am
Hi! 

I am new asp developer and want to set things in 3 column and display 4 rows in each column

How is the code ? Does code below need to add more ???

<%@ LANGUAGE = "VBScript"%>
<%
'open a database connection
Set dataconnection = Server.CreateObject("ADODB.Connection")
dataconnection.Open "DSN=yourDSNhere"
Response.Write "<html><body>"
'execute your select statement
query = "SELECT * FROM TABLE"
Set rs = dataconnection.Execute(query)
'If there are records in table
If Not rs.EOF Then
Response.Write"<table border=1>"
LinkCount = 0
' Do until the end of all records
Do Until rs.EOF
'change 5 to any number of columns you like 
  If LinkCount Mod 3 = 0 Then
If LinkCount <> 0 Then Response.Write"</tr>"
Response.Write"<tr><td>"&rs("NAME")&"<br>"&rs("DESCRIP")&"</td>"
Else
Response.Write"<td>"&rs("NAME")&"<br>"&rs("DESCRIP")&"</td>"
End If
 
LinkCount = LinkCount + 1
'loop till end of records
rs.MoveNext
Loop
Response.Write"</tr></table>"
'Close 
rs.Close
Set rs = Nothing
Else 

'Write no records in there are no records
Response.Write"Sorry, no records were found!"



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net