sorting output

Discussion in 'ASP General' started by Milton Snider, Jul 26, 2005.

  1. 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
     
    Milton Snider, Jul 26, 2005
    #1
    1. Advertising

  2. Milton Snider

    Roland Hall Guest

    "Milton Snider" wrote in message
    news:...
    :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
     
    Roland Hall, Jul 26, 2005
    #2
    1. Advertising

  3. Re: sorting output thanks and works great

    "Roland Hall" <nobody@nowhere> wrote in message
    news:...
    > "Milton Snider" wrote in message
    > news:...
    > :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
    >
    >
     
    Milton Snider, Jul 26, 2005
    #3
  4. Milton Snider

    Roland Hall Guest

    Re: sorting output thanks and works great

    "Milton Snider" wrote in message
    news:...
    : "Roland Hall" wrote in message
    : news:...
    : > "Milton Snider" wrote in message
    : > news:...
    : > :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
     
    Roland Hall, Jul 26, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Morgan

    Ordered output without "sorting" array

    Simon Morgan, Jul 26, 2005, in forum: C Programming
    Replies:
    2
    Views:
    300
    Michael Mair
    Jul 26, 2005
  2. Replies:
    2
    Views:
    1,464
    James Kanze
    Jul 6, 2010
  3. Jason
    Replies:
    0
    Views:
    398
    Jason
    Oct 4, 2006
  4. Tom Kirchner

    sorting by multiple criterias (sub-sorting)

    Tom Kirchner, Oct 11, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    485
    Michael Budash
    Oct 11, 2003
  5. Íéêüëáïò Êïýñáò

    Sorting a set works, sorting a dictionary fails ?

    Íéêüëáïò Êïýñáò, Jun 10, 2013, in forum: Python
    Replies:
    12
    Views:
    168
    Ulrich Eckhardt
    Jun 10, 2013
Loading...

Share This Page