472,139 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,139 software developers and data experts.

how to display data in 3 columns by 4 rows format

All,

I will be eternally greatful if someone can provide snippet of code,
URL or reference material that shows how to display data in a "n
colums * n rows" format.

I am new to ASP and have looked everywhere that I could, but I have
not found an example where data can be formatted to be displayed in a
3 * 4 foramt, like many of the professional sites would do (actually
rows and columns can be any number of rows and columns) All the
examples that I have seen, show data displayed in a top down format.

Best Regards,

Addi
Jul 19 '05 #1
3 5243
Take a look at the samples here. http://www.aspfaq.com/show.asp?id=2247

Ray at home

"addi" <ad****@hotmail.com> wrote in message
news:6f************************@posting.google.com ...
All,

I will be eternally greatful if someone can provide snippet of code,
URL or reference material that shows how to display data in a "n
colums * n rows" format.

I am new to ASP and have looked everywhere that I could, but I have
not found an example where data can be formatted to be displayed in a
3 * 4 foramt, like many of the professional sites would do (actually
rows and columns can be any number of rows and columns) All the
examples that I have seen, show data displayed in a top down format.

Best Regards,

Addi

Jul 19 '05 #2
ljb
Even though Addi didn't specifically ask I'll mention a slight "enhancement"
to the code here.

"Ray at <%=sLocation%>" <myFirstNameATlane34dotKOMM> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Take a look at the samples here. http://www.aspfaq.com/show.asp?id=2247

Ray at home


I like to see my tables present data ordered such that columns are read from
top down rather than rows across. To do that almost always requires an array
(unless you use XML and XSLT) that can be accessed by index. In the second
example with a recordset that can be accomplished by creating an array with
ADO's getrows method. The key is to predetermine how many columns are
desired and how many rows of data are provided. If you want 5 columns go to
every rows mod 5 array index and so on.

LJB
Jul 19 '05 #3
Well I got the data to display the way I wanted using the example provided
in the following links. Now I am stuck with another dilema. I am trying to
implement paging within my example and it does not seem to page thru. I have
used two independent examples (1 for paging, the other for displaying data)
and they both seem to work fine. When I combine them, it only processes the
first 9 records and paging does not seem to work. Any input on where the
code is broken would be greatly appreciated. The following is a working
example, using the pubs database in SQL Server.
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=wbsql", "sa", "golf"

set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3 ' adUseClient
rs.Open "Select * from pubs..authors", conn
intPageCount = rs.PageCount
rs.PageSize = 9

Select Case Request("Action")
case "<<"
intpage = 1
case "<"
intpage = Request("intpage")-1
if intpage < 1 then intpage = 1
case ">"
intpage = Request("intpage")+1
if intpage > intPageCount then intpage = IntPageCount
Case ">>"
intpage = intPageCount
case else
intpage = 1
end select
%>
<table border="2" align=center>
<%
numCols = 3
intPage = rs.AbsolutePage
rsPageSize = rs.PageSize
i = 0

Do while i < rsPageSize
needFooter = true

if i mod numCols = 0 then
response.write "<tr>"
end if

response.write "<td align=center>"
response.Write "<P>" & rs(0) & "</P>"
response.Write "<P>" & rs(1) & "</P>"
response.Write "<P>" & rs(2) & "</P>"

response.write "</td>"

if i mod numCols = numCols - 1 then
response.write "</tr>"
needFooter = false
end if
i = i + 1
rs.MoveNext
Loop

if needFooter then
response.write "<td colspan=" &_
numCols - (i mod numCols) &_
"> </td></tr>"
end if
response.write "</table>"

rs.Close
set rs = Nothing
conn.Close
set conn = nothing
%>
</table>
<%

%>
<form name="MovePage" action="test1.asp" method="post" ID="Form1">
<input type="hidden" name="intpage" value="<%=intpage%>" ID="Hidden1">
<input type="submit" name="action" value="<<" ID="Submit1">
<input type="submit" name="action" value="<" ID="Submit2">
<input type="submit" name="action" value=">" ID="Submit3">
<input type="submit" name="action" value=">>" ID="Submit4">
Page: <%=Intpage & " of " & intpagecount%>
</form>
</BODY>
</HTML>
Best Regards,

Addi
"ljb" <.> wrote in message news:eO**************@tk2msftngp13.phx.gbl...
Even though Addi didn't specifically ask I'll mention a slight "enhancement" to the code here.

"Ray at <%=sLocation%>" <myFirstNameATlane34dotKOMM> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Take a look at the samples here. http://www.aspfaq.com/show.asp?id=2247

Ray at home

I like to see my tables present data ordered such that columns are read

from top down rather than rows across. To do that almost always requires an array (unless you use XML and XSLT) that can be accessed by index. In the second
example with a recordset that can be accomplished by creating an array with ADO's getrows method. The key is to predetermine how many columns are
desired and how many rows of data are provided. If you want 5 columns go to every rows mod 5 array index and so on.

LJB

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by ben moretti | last post: by
1 post views Thread by Craig Banks | last post: by
4 posts views Thread by Joe Van Meer | last post: by
6 posts views Thread by Hutty | last post: by
7 posts views Thread by =?Utf-8?B?aWxy?= | last post: by
1 post views Thread by xiao | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.