sorting output

M

Milton Snider

I have a table of about 20 Categories. I currently have them displayed
accross the page in a table from left to right in 3 columns. like this:
abuse cmecf credit/etc
dismissal presumptions

You will notice the sort runs from left to right. I would like the sort to
run vertically like this:
abuse dismissal
cmecf presumptions
credit/etc

I am outputting from an access table into an html table via asp. Does
anyone have a trick to get the output the way I want it.
Could I populate an array and then output like this:

array(1) array(4) array(7)
array(2) array(5) array(8)

Any help is appreciated.

thanks
Milton
 
R

Roland Hall

in message
:I have a table of about 20 Categories. I currently have them displayed
: accross the page in a table from left to right in 3 columns. like this:
: abuse cmecf credit/etc
: dismissal presumptions
:
: You will notice the sort runs from left to right. I would like the sort
to
: run vertically like this:
: abuse dismissal
: cmecf presumptions
: credit/etc
:
: I am outputting from an access table into an html table via asp. Does
: anyone have a trick to get the output the way I want it.
: Could I populate an array and then output like this:
:
: array(1) array(4) array(7)
: array(2) array(5) array(8)

Assume rs is the recordset variable and arr is the 2-dimensional array
created using GetRows()

If you used GetRows, you can easily do this.

Const numColumns = 3
dim numRecords, arr, rowCounter, colCounter, displayName

' connect to database and return data

arr = rs.GetRows()

Response.Write "<table width=""100%"">"
numRecords = ubound(arr,2) + 1
if numRecords mod numColumns = 0 then
numRows = numRecords\numColumns
Else
numRows = numRecords\numColumns + 1
End if

For rowCounter = 1 to numRows
Response.Write "<tr>"
For colCounter = 0 to numColumns - 1
If rowCounter + colCounter * numRows <= numRecords then
displayName = arr(0, rowCounter + colCounter * numRows - 1)
Response.Write "<td style=""width: 33%"">" & arr(1, rowCounter +
colCounter * numRows - 1) & displayName & "</td>"
Else
Response.write "<td>&nbsp;</td>"
end if
Next
Response.Write "</tr>"
Next

I've done this with two columns. I've made some changes to work with 3 but
it's not tested.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
M

Milton Snider

Roland Hall said:
in message
:I have a table of about 20 Categories. I currently have them displayed
: accross the page in a table from left to right in 3 columns. like this:
: abuse cmecf credit/etc
: dismissal presumptions
:
: You will notice the sort runs from left to right. I would like the sort
to
: run vertically like this:
: abuse dismissal
: cmecf presumptions
: credit/etc
:
: I am outputting from an access table into an html table via asp. Does
: anyone have a trick to get the output the way I want it.
: Could I populate an array and then output like this:
:
: array(1) array(4) array(7)
: array(2) array(5) array(8)

Assume rs is the recordset variable and arr is the 2-dimensional array
created using GetRows()

If you used GetRows, you can easily do this.

Const numColumns = 3
dim numRecords, arr, rowCounter, colCounter, displayName

' connect to database and return data

arr = rs.GetRows()

Response.Write "<table width=""100%"">"
numRecords = ubound(arr,2) + 1
if numRecords mod numColumns = 0 then
numRows = numRecords\numColumns
Else
numRows = numRecords\numColumns + 1
End if

For rowCounter = 1 to numRows
Response.Write "<tr>"
For colCounter = 0 to numColumns - 1
If rowCounter + colCounter * numRows <= numRecords then
displayName = arr(0, rowCounter + colCounter * numRows - 1)
Response.Write "<td style=""width: 33%"">" & arr(1, rowCounter +
colCounter * numRows - 1) & displayName & "</td>"
Else
Response.write "<td>&nbsp;</td>"
end if
Next
Response.Write "</tr>"
Next

I've done this with two columns. I've made some changes to work with 3
but
it's not tested.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
R

Roland Hall

in message
: "Roland Hall" wrote in message
: : > "Milton Snider" wrote in message
: > : > :I have a table of about 20 Categories. I currently have them displayed
: > : accross the page in a table from left to right in 3 columns. like
this:
: > : abuse cmecf credit/etc
: > : dismissal presumptions
: > :
: > : You will notice the sort runs from left to right. I would like the
sort
: > to
: > : run vertically like this:
: > : abuse dismissal
: > : cmecf presumptions
: > : credit/etc
: > :
: > : I am outputting from an access table into an html table via asp. Does
: > : anyone have a trick to get the output the way I want it.
: > : Could I populate an array and then output like this:
: > :
: > : array(1) array(4) array(7)
: > : array(2) array(5) array(8)
: >
: > Assume rs is the recordset variable and arr is the 2-dimensional array
: > created using GetRows()
: >
: > If you used GetRows, you can easily do this.
: >
: > Const numColumns = 3
: > dim numRecords, arr, rowCounter, colCounter, displayName
: >
: > ' connect to database and return data
: >
: > arr = rs.GetRows()
: >
: > Response.Write "<table width=""100%"">"
: > numRecords = ubound(arr,2) + 1
: > if numRecords mod numColumns = 0 then
: > numRows = numRecords\numColumns
: > Else
: > numRows = numRecords\numColumns + 1
: > End if
: >
: > For rowCounter = 1 to numRows
: > Response.Write "<tr>"
: > For colCounter = 0 to numColumns - 1
: > If rowCounter + colCounter * numRows <= numRecords then
: > displayName = arr(0, rowCounter + colCounter * numRows - 1)
: > Response.Write "<td style=""width: 33%"">" & arr(1, rowCounter +
: > colCounter * numRows - 1) & displayName & "</td>"
: > Else
: > Response.write "<td>&nbsp;</td>"
: > end if
: > Next
: > Response.Write "</tr>"
: > Next
: >
: > I've done this with two columns. I've made some changes to work with 3
: > but
: > it's not tested.

I got the idea a long time ago from a guy name Pete Draigh @
businessstrategy.com

Glad it worked for you.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top