473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Formatting grouped results

4
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.html

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_designerLetter.EOF Then
ar = RS_designerLetter.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><strong>" & CurrentDesigner & "</strong><br>"
End if
Response.Write ar(1,i) & ar(2,i) & "&nbsp;&nbsp;|&nbsp;&nbsp;"
Next
Response.Write "<br><br>End of Records Found</p>"
Else
Response.Write "<p>No Records Were Retrieved</p>"
End if

End if
%>
Jul 4 '07 #1
2 1152
Try This...

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim ar, CurrentDesigner, NextDesigner
  3. Dim sOutPut
  4.  
  5. If Not RS_designerLetter.EOF Then
  6. ar = RS_designerLetter.GetRows
  7.  
  8. Dim titles
  9.  
  10. If isarray(ar) Then
  11. CurrentDesigner = ar(0,0)
  12. sOutPut = "<p><strong>" & CurrentDesigner & "</strong><br>"
  13.  
  14. For i = 0 to ubound(ar,2)
  15.  
  16. NextDesigner = ar(0,i)
  17. If CurrentDesigner < NextDesigner then
  18. CurrentDesigner = NextDesigner
  19. sOutPut = sOutPut & "<br><strong>" & CurrentDesigner & "</strong><br>"
  20. End if
  21. sOutPut = sOutPut & "&nbsp;&nbsp;" & ar(1,i) & ar(2,i) & "&nbsp;&nbsp;|"
  22.  
  23. Next
  24.  
  25. sOutPut = Left(sOutPut,Len(sOutPut)-1)
  26. Response.Write sOutPut
  27.  
  28. Response.Write "<br><br>End of Records Found</p>"
  29. Else
  30. Response.Write "<p>No Records Were Retrieved</p>"
  31. End if
  32.  
  33. End if
  34. %>
  35.  
Jul 4 '07 #2
Jejune
4
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



Try This...

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim ar, CurrentDesigner, NextDesigner
  3. Dim sOutPut
  4.  
  5. If Not RS_designerLetter.EOF Then
  6. ar = RS_designerLetter.GetRows
  7.  
  8. Dim titles
  9.  
  10. If isarray(ar) Then
  11. CurrentDesigner = ar(0,0)
  12. sOutPut = "<p><strong>" & CurrentDesigner & "</strong><br>"
  13.  
  14. For i = 0 to ubound(ar,2)
  15.  
  16. NextDesigner = ar(0,i)
  17. If CurrentDesigner < NextDesigner then
  18. CurrentDesigner = NextDesigner
  19. sOutPut = sOutPut & "<br><strong>" & CurrentDesigner & "</strong><br>"
  20. End if
  21. sOutPut = sOutPut & "&nbsp;&nbsp;" & ar(1,i) & ar(2,i) & "&nbsp;&nbsp;|"
  22.  
  23. Next
  24.  
  25. sOutPut = Left(sOutPut,Len(sOutPut)-1)
  26. Response.Write sOutPut
  27.  
  28. Response.Write "<br><br>End of Records Found</p>"
  29. Else
  30. Response.Write "<p>No Records Were Retrieved</p>"
  31. End if
  32.  
  33. End if
  34. %>
  35.  
Jul 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Colleyville Alan | last post by:
I am using Access and have embedded the ActiveX control Formula One that came with Office 2000. (ver 3.04). I have created and formatted a spreadsheet and now I want to copy the info with...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
8
by: nico3334 | last post by:
I have a database that has a Date column (1/1/2007) and a Data column that has numerical data. I am currently running a query to sum the Data column for a certain month and grouped by day (There is...
12
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I'm doing a web app in VB/Dot Net 2.0. I'm probably a bit rusty and I have no experience using the repeater control. I have a user control I've created with multiple properties. I've created a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.