Formatting grouped results

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jejune
    New Member
    • Jul 2007
    • 4

    Formatting grouped results

    I recently saw a post that tackled an issue I was struggling with. It allowed me to get the results I wanted, but I need the expand on that.

    Original Post
    http://www.thescripts. com/forum/thread610974.ht ml

    I'm am working with ASP and I'm am filtering results from an Access DB.

    I have the season, year and designer stored in the Database.

    Example:
    Designer | Season | Year
    Paul Smith | AW | 07
    Paul Smith | SS | 07
    Paul Smith | AW | 06
    Paul Smith | SS | 06
    ...and so on back to SS85

    Paco Rabanne | AW | 07
    Paco Rabanne | SS | 07
    ...and so on


    My query looks for all Fashion Designers in Menswear Where the first letter of their name has been specified by the user. e.g. search = P

    I would like to format thes returned result grouped by designer and to display the most recent 4 seasons out of a long list. e.g. AW07, SS07, AW06, SS06

    Paul Smith
    aw07 | ss07 | aw06 | ss06

    Paco Rabanne
    aw07 | ss07 | aw06 | ss06

    I can group the results but I only want the dividers ' | ' to show between the seasons and not after the last result.

    Currently my results return like this:

    Paul Smith
    aw07 | ss07 | aw06 | ss06 |

    How can I edit my array/loop to sort this?


    My Code

    <%
    Dim ar, CurrentDesigner , NextDesigner

    If Not RS_designerLett er.EOF Then
    ar = RS_designerLett er.GetRows

    Dim titles

    If isarray(ar) Then
    CurrentDesigner = ar(0,0)
    Response.Write "<p><strong >" & CurrentDesigner & "</strong><br>"

    For i = 0 to ubound(ar,2)
    NextDesigner = ar(0,i)
    If CurrentDesigner < NextDesigner then
    CurrentDesigner = NextDesigner
    Response.Write "<br><stron g>" & CurrentDesigner & "</strong><br>"
    End if
    Response.Write ar(1,i) & ar(2,i) & "&nbsp;&nbsp;|& nbsp;&nbsp;"
    Next
    Response.Write "<br><br>En d of Records Found</p>"
    Else
    Response.Write "<p>No Records Were Retrieved</p>"
    End if

    End if
    %>
  • snavebelac
    New Member
    • Jun 2007
    • 6

    #2
    Try This...

    Code:
    <%
    Dim ar, CurrentDesigner, NextDesigner
    Dim sOutPut
    
    If Not RS_designerLetter.EOF Then
    ar = RS_designerLetter.GetRows
    
    Dim titles
    
    If isarray(ar) Then
    CurrentDesigner = ar(0,0)
    sOutPut = "<p><strong>" & CurrentDesigner & "</strong><br>"
    
    For i = 0 to ubound(ar,2)
    
    NextDesigner = ar(0,i)
    If CurrentDesigner < NextDesigner then
    CurrentDesigner = NextDesigner
    sOutPut = sOutPut & "<br><strong>" & CurrentDesigner & "</strong><br>"
    End if
    sOutPut = sOutPut & "&nbsp;&nbsp;" & ar(1,i) & ar(2,i) & "&nbsp;&nbsp;|"
    
    Next
    
    sOutPut = Left(sOutPut,Len(sOutPut)-1)
    Response.Write sOutPut
    
    Response.Write "<br><br>End of Records Found</p>"
    Else
    Response.Write "<p>No Records Were Retrieved</p>"
    End if
    
    End if
    %>

    Comment

    • Jejune
      New Member
      • Jul 2007
      • 4

      #3
      Almost

      Unfortunatley the script removed the last divider ' | ' on the last designer. Rather than the last divider on each designer.

      Result:

      Paul Smith
      aw07 | ss07 | aw06 | ss06 |

      Paco Rabanne
      aw07 | ss07 | aw06 | ss06 |

      Pierre Henri Mattout
      aw07 | ss07 | aw06 | ss06



      Originally posted by snavebelac
      Try This...

      Code:
      <%
      Dim ar, CurrentDesigner, NextDesigner
      Dim sOutPut
      
      If Not RS_designerLetter.EOF Then
      ar = RS_designerLetter.GetRows
      
      Dim titles
      
      If isarray(ar) Then
      CurrentDesigner = ar(0,0)
      sOutPut = "<p><strong>" & CurrentDesigner & "</strong><br>"
      
      For i = 0 to ubound(ar,2)
      
      NextDesigner = ar(0,i)
      If CurrentDesigner < NextDesigner then
      CurrentDesigner = NextDesigner
      sOutPut = sOutPut & "<br><strong>" & CurrentDesigner & "</strong><br>"
      End if
      sOutPut = sOutPut & "&nbsp;&nbsp;" & ar(1,i) & ar(2,i) & "&nbsp;&nbsp;|"
      
      Next
      
      sOutPut = Left(sOutPut,Len(sOutPut)-1)
      Response.Write sOutPut
      
      Response.Write "<br><br>End of Records Found</p>"
      Else
      Response.Write "<p>No Records Were Retrieved</p>"
      End if
      
      End if
      %>

      Comment

      Working...