How to solve this problem-

Results 1 to 7 of 7

Thread: How to solve this problem-

  1. #1
    Kentium Guest

    Default How to solve this problem- I&#039;ve been working on my document download center for the intranet...and it&#039;s coming along nicely- thanks for everyone&#039;s help!<BR><BR>The issue i&#039;ve got now-<BR><BR>I&#039;m returning records from my db into a results page- it shows all the columns and you can sort by columns, etc.<BR><BR>In particular- someone can click on "Sales" and see only the available sales documents. Under the sales catagory- I&#039;ve broken it down a little further into these sub-catagories:<BR>Sales_CorpLit, Sales_FeatureSheets, Sales_Training, Sales_Pricing.<BR><BR>What I would like to do is- when someone clicks on Sales it will return all the above mentioned sub-catagories (that begin with Sales_), but it will put in a header between each section that says what catagory is being listed. Make sense?<BR><BR>When somebody choose Sales, I already do a specific SQL query to pull only Sales records, so my thinking is to populate an array with the various sub-catagories, and then do some kind of for each loop to display the records.<BR><BR>For each element in array, display the correct results for that catagory, and then move on to the next catagory.<BR><BR>Am I going about this the right way? I&#039;m a little lost on pulling together the syntax to make it happen.<BR><BR>Any help is HUGELY appreciated.<BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: How to solve this problem-

    I have a similar function on a site I&#039;m developing. I did it like this. <BR><BR>First, I created 2 tables. One is Cat, the other SubCat. <BR><BR>In Cat there are 2 colums, one for the catagory name, the other is the catID (autonumber). <BR><BR>In subcat there are 3 colums. SCatName, SCatID and CatID. I use the CatID to perform the Join. <BR><BR>On my page, I pull the CatID from the querystring (depending on how you&#039;re developing it, the varible that contains the CatID may be in a recordset, form, etc)<BR><BR>I then have an SQL statement like this<BR><BR>"Select scatname from scat where catID=&#039;"&catID&"&#039;"<BR><BR>And that&#039;s all folks. <BR><BR><BR><BR><BR>

  3. #3
    Kentium Guest

    Default I'm more confused here-

    I think I can get the SQL string built...i&#039;m more lost on doing the FOR EACH loop thing to get the Sub-Catagories and associated documents delimited in my results page.<BR><BR>I&#039;m thinking about something like this now-<BR><BR>If deptOrder = Sales then<BR> Sales_Cat1 = SELECT FROM ufiles WHERE catagory LIKE %Sales_CorpLit%<BR>and<BR> Sales_Cat2 = SELECT FROM ufiles WHERE catagory LIKE %Sales_Pricing%<BR>etc...<BR>End If<BR><BR>Then I&#039;d just do multiple GetRows calls, putting each SQL string into a seperate array. Then i&#039;d just loop through the results in my results page.<BR><BR>For some reason, this seems like the ***-backwards way to do it.<BR><BR>Maybe I could use GetRows to pull down ALL of the Sales_ docs, and then some how loop through the sub-catagories afterwards?<BR><BR>Ugh...still confused.<BR>

  4. #4
    Join Date
    Dec 1969

    Default Could you show a small

    example on how the final result should look like? I very much remember doing something similar but have to really scratch my brain, example would help.

  5. #5
    Kentium Guest

    Default Example-

    Sales-<BR>----------------------<BR>Sales_Pricing-<BR>database results<BR>database results<BR>database results<BR>----------------------<BR>Sales_CorpLiterature-<BR>database results<BR>database results<BR>database results<BR>----------------------<BR>Sales_Training-<BR>database results<BR>database results<BR>database results<BR>----------------------<BR><BR>etc...

  6. #6
    Join Date
    Dec 1969

    Default RE: Example-

    Can you get all the results w/ the category name in one recordset? like:<BR><BR>SELECT FROM ufiles WHERE catagory LIKE %Sales_% <BR><BR>..and add order by catagory.<BR><BR>Then as you loop through your recordset do something like:<BR><BR>strCurrentCategory = ""<BR>For i=0 to Ubound()<BR> strCategory = arrYourArray(,i)<BR> if strCategory &#060;&#062; strCurrentCategory<BR> &#039;Write the Category<BR> strCurrentCategory = strCategory<BR> end if <BR> <BR> &#039;Write the database result<BR>Next<BR><BR>If that makes no sense you might look want to look into data shaping. I&#039;ve never really used it, but it could do what you want.

  7. #7
    Kentium Guest

    Default wouldn't that mean

    I&#039;d have to do separate lookups for each catagory? That would be taxing on the database, no?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts