473,808 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using an ARRAY to format retrieved records

4 New Member
I'd like to thank snavebelac for his help so far in this problem.

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 | Url
Paul Smith | AW | 07 | /aw07/menswear/paul_smith
Paul Smith | SS | 07 | /ss07/menswear/paul_smith
Paul Smith | AW | 06 | /aw06/menswear/paul_smith
Paul Smith | SS | 06 | /ss06/menswear/paul_smith
...and so on back to SS85

Paco Rabanne | AW | 07 | /aw07/menswear/paco_rabanne
Paco Rabanne | SS | 07 | /aw07/menswear/paco_rabanne
...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 results grouped by designer and to display the most recent 4 seasons out of a long list. e.g. AW07, SS07, AW06, SS06. Each season is a link.

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

Currently my results return like this:

Paul Smith
aw07 | ss07 | aw06 | ss06 |

Paco Rabanne
aw07 | ss07 | aw06 | ss06 |

Pierre Henri Mattout
aw07 | ss07 | aw06 | ss06

and I would like it to look like this...

Paul Smith
aw07 | ss07 | aw06 | ss06

Paco Rabanne
aw07 | ss07 | aw06 | ss06

Pierre Henri Mattout
aw07 | ss07 | aw06 | ss06


Where do I need to edit within my array to recifiy this?


My Code

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim ar, CurrentDesigner, NextDesigner
  3. Dim sOutPut
  4.  
  5. If Not RS_designerLetter.EOF Then
  6. 'Get all rows and 4 specific columns from query
  7. ar = RS_designerLetter.GetRows(, , Array("designer", "season", "collectionYear", "url"))
  8.  
  9. If isarray(ar) Then
  10. CurrentDesigner = ar(0,0)
  11. sOutPut = "<p><strong>" & CurrentDesigner & "</strong><br>"
  12.  
  13. ' Gets total number of rows in the array
  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 & "<a href=""" & ar(3,i) & """>" & ar(1,i) & ar(2,i) & "</a>&nbsp;&nbsp;|&nbsp;&nbsp;"
  22.  
  23. Next
  24. 'Using Len here only removes the divider on the last record of the last designer 
  25. 'Need it to remove the last divider on the last record of each desginer
  26. sOutPut = Left(sOutPut,Len(sOutPut)-25)
  27. Response.Write(sOutPut)
  28.  
  29. Response.Write("<br><br>End of Records Found</p>")
  30. Else
  31. Response.Write("<p>No Records Were Retrieved</p>")
  32. End if
  33.  
  34. End if
  35. %>
Jul 5 '07 #1
3 1855
jhardman
3,406 Recognized Expert Specialist
wow, that is totally not how I would have done it, but it is very succinct and well-done. There are a couple ways you could fix this, you could remove the last character of the string every time you start a new line (this appears to be how snavebelac removes the last | of the last line) or you could count how many records you have listed, and on the fourth, don't put in a "|"

Jared
Jul 5 '07 #2
Jejune
4 New Member
I have applied a technique that does not use an array. But this resulted in returning the number of returned season x the designer name.

E.G.
If there are 4 seasons for Paul Smith then Paul Smith repeats 4 times will all 4 season underneath the designer name.

Paul Smith
aw07 ss07 aw06 ss06

and then repeats 3 more times same as above


If I limit the recordset RS_designersByC atCity to select where seasonYear = aw07 then it returns the designer name only once with the all seasons underneath.

However, designers who do not have a aw07 show (have ss07,aw06,etc), do not show up in the return results.

Paul Smith
aw07 ss07 aw06 ss06

Designers like Petra Petrov will not appear
Petra Petrov
ss07 aw06




This attempt uses 2 recordsets, one within the other.


Expand|Select|Wrap|Line Numbers
  1.   <table width="400" border="0" cellspacing="8" cellpadding="0">
  2.     <tr>
  3.       <td><%=(RS_designersByCatCity.Fields.Item("designer").Value)%></td>
  4.     </tr>
  5.     <tr>
  6.     <td>
  7.     <%
  8.               FilterParam = RS_designersByCatCity.Fields.Item("designerID").Value
  9.               RS_designersSecond.Filter = "designerID = " & FilterParam
  10.               While (NOT RS_designersSecond.EOF)
  11.      %>
  12.      <%=(RS_designersSecond.Fields.Item("seasonYear").Value)%>&nbsp;&nbsp;
  13.       <%
  14.     RS_designersSecond.MoveNext()
  15.     Wend
  16.        %>      
  17.       </td>
  18.       </tr>
  19.   </table>
  20.   <% 
  21.   Repeat2__index=Repeat2__index+1
  22.   Repeat2__numRows=Repeat2__numRows-1
  23.   RS_designersByCatCity.MoveNext()
  24.   Wend
  25. %>

Recordset query if I filter by season 'desSeasonCurr' contains 'aw07' filters from the column 'seasonYear'

Expand|Select|Wrap|Line Numbers
  1. RS_designersByCatCity.Source = "SELECT designer, seasonYear, url, designerID, ID_url  FROM QY_designerURLS  WHERE categoryID = " + Replace(RS_designersByCatCity__desCategoryID, "'", "''") + " AND cityID = " + Replace(RS_designersByCatCity__desCityID, "'", "''") + " AND seasonYear = '" + Replace(RS_designersByCatCity__desSeasonCurr, "'", "''") + "'  ORDER BY designer, collectionYear DESC, season ASC"
Jul 6 '07 #3
jhardman
3,406 Recognized Expert Specialist
well I'm glad you found a solution, even though it wasn't what I suggested. Thanks for sharing what you found.

Jared
Jul 6 '07 #4

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

Similar topics

1
2012
by: Rvenkatesh | last post by:
How to use array string in C#.Net to compare and replace characters between strings using function.
4
4408
by: rafeekb | last post by:
Hello All, Is there any way to export data in the IXF version 1 format from a DB2 v8.2 database ? The problem I am facing is to get the data from a v8.2 database which produces a version 2 IXF and import it on to a v5.2 database which knows only about version 1 IXF format. Any suggestions, help is much appreciated.
1
2993
by: nel | last post by:
hi.. i want to know how to insert data using array in mysql where the data stored in field given? this field_name i taken from database.... thanks a lot...
0
958
by: sachin10 | last post by:
hi i m sachin, i m new to VB programming.i face some problem regarding the sorting of text file contents using arrays.text file have data in the format as below seq |consumerid|status1|status2|meter no1|meter no2|nameof consumer|routeno 234133210003040002222222222000003333333123098sasdc scasdsadsd9041 231433104000267232222278222000003333333123098shskd fkscasdsade9012 this is the format of text file.there are thosands of records in this...
12
9610
by: astri | last post by:
i`m doing my thesis comparing CORDIC with polynomial in counting arctan with fixed point. I`m using Q15 format now. I`m using this site CORDIC arctan as a referenced when making with floating point. The problem there`s a lot of error when i try to make it with fixed point. this is my program #include "Unit1.h" #include "math.h" #include "fixed_math.hpp" #define MAXBITS 15 static float invGain1;
2
2577
by: palani12kumar | last post by:
Hi i've implemented a linear Queue using array. But i've been struck up with a doubt!!!!! Let me tell my problem with an example so that it can be clear. Size of the Queue(array) is 5. im initializing the front and rear to 0. I continously add five elements to the Queue, so that now the rear points to the 4th position of the array and now the queue is full. Now i delete all the five elements and now the Front and the Rear points at...
1
3683
shoonya
by: shoonya | last post by:
i am using array as a data type in my db .... ( sequence integer ) ; and it stores a value let {1,2,3,4,5}
2
5218
by: berrylthird | last post by:
This question was inspired by scripting languages such as JavaScript. In JavaScript, I can access members of a class using array syntax as in the following example: var myInstance:myClass = new myClass(); myInstance.member_0 = memberValue_0; // absolute notation myInstance = memberValue_0; // relative notation myInstance = memberValue_0; // nominal notation You can initialize a struct in C/C++ like you would an array, as with the...
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10633
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10375
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.