Print Page | Close Window

How can I do this?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=13686
Printed Date: 30 March 2026 at 1:12pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: How can I do this?
Posted By: zMaestro
Subject: How can I do this?
Date Posted: 07 February 2005 at 3:54am
I want to make a site map, to display the results as this:
Quote
1.0.0.0.0          Index
          1.1.0.0.0          Parent / Future Students
                1.1. 1.0.0          BECOMING A GIS STUDENT
                &nbs p;            1.1.1.1.0          Admissions
                &nbs p;            1.1.1.1.1          Admissions - Graduate
                &nbs p;            1.1.1.1.2          Admissions - Int
                &nbs p;            1.1.1.1.3          Admissions - Underg.
                &nbs p;  1.1.1.2.0          Financial Aid & Scholarships 
                &nbs p;  1.1.1.3.0          First Year Experience 
                &nbs p;  1.1.1.4.0          Transfer    
                &nbs p;  1.1.1.5.0          Tuition & Costs
                &nbs p;  1.1.1.6.0          Washington Residency 
                1.1. 2.0          UNIVERSITY RESOURCES
                &nbs p;      1.1.2.1          Access to Technology
                &nbs p;      1.1.2.2          Disability Support Center 
                &nbs p;      1.1.2.3          Family Resources
                &nbs p;      1.1.2.4          Health & Wellness
                1.1. 3.0          ACTIVITIES & CULTURE
                &nbs p;      1.1.3.1          Clubs & Organizations
                &nbs p;      1.1.3.2          KEWU 89.5 FM 
                       1.1.3.3          Outdoor Recreation (EPIC) 
                1.1. 4.0          LIVING ON CAMPUS
                &nbs p;      1.1.4.1          Housing & Dining  
                &nbs p;      1.1.4.2          Residential Hall Tour 
                &nbs p;      1.1.4.3          Safety
I don't know if i'm clear or not, it is a tree structure that display results from database, every time there is a subcategory it display it in a tree form?
plz give advices.
thanks.



Replies:
Posted By: zMaestro
Date Posted: 07 February 2005 at 5:52am

<%
Set  rsA1 = Server.CreateObject("ADODB.Recordset")
SQLA1= "SELECT Level1E, COUNT(Level1E) AS majorCategories FROM Levels WHERE DUserName = '"&DUserName&"' AND Show = 'y' "
SQLA1= SQLA1 & "GROUP BY Level1E ORDER BY Level1E;"
rsA1.Open SQLA1, Conn, 2, 2
on error resume next
Response.Write "<UL>"
Do While NOT  rsA1.BOF AND NOT  rsA1.EOF
response.write "<LI>"&rsA1("Level1E")&"</LI>"


Set  rsA2 = Server.CreateObject("ADODB.Recordset")
SQLA2= "SELECT Level2E, COUNT(Level2E) AS majorCategories FROM Levels WHERE DUserName = '"&DUserName&"' AND Show = 'y' AND Level1E = '"&rsA1("Level1E")&"' "
SQLA2= SQLA2 & "GROUP BY Level2E ORDER BY Level2E;"
rsA2.Open SQLA2, Conn, 2, 2
on error resume next
Response.Write "<UL>"
Do While NOT  rsA2.BOF AND NOT  rsA2.EOF
response.write "<LI>"& rsA2("Level2E")&"</LI>"

 Set  rsB1 = Server.CreateObject("ADODB.Recordset")
 SQLB1= "SELECT Level3E, COUNT(Level3E) AS majorCategories FROM Levels WHERE DUserName = '"&DUserName&"' AND Show = 'y' AND Level1E = '"&rsA1("Level1E")&"'  AND Level2E = '"&rsA2("Level2E")&"' "
 SQLB1= SQLB1 & "GROUP BY Level3E ORDER BY Level3E;"
 rsB1.Open SQLB1, Conn, 2, 2
 on error resume next
 Response.Write "<UL>"
 Do While NOT  rsB1.BOF AND NOT  rsB1.EOF
 response.write "<LI>"& rsB1("Level3E")&"</LI>"


 Set  rsB2 = Server.CreateObject("ADODB.Recordset")
 SQLB2= "SELECT Level4E, COUNT(Level4E) AS majorCategories FROM Levels WHERE DUserName = '"&DUserName&"' AND Show = 'y' AND Level1E = '"&rsA1("Level1E")&"' AND Level2E = '"&rsA2("Level2E")&"' AND Level3E = '"&rsB1("Level3E")&"' "
 SQLB2= SQLB2 & "GROUP BY Level4E ORDER BY Level4E;"
 rsB2.Open SQLB2, Conn, 2, 2
 on error resume next
 Response.Write "<UL>"
 Do While NOT  rsB2.BOF AND NOT  rsB2.EOF
 response.write "<LI>"& rsB2("Level4E")&"</LI>"


 Set  rsA3 = Server.CreateObject("ADODB.Recordset")
 SQLA3= "SELECT Level5E, COUNT(Level5E) AS majorCategories FROM Levels WHERE DUserName = '"&DUserName&"' AND Show = 'y' AND Level1E = """&rsA1("Level1E")&""" AND Level2E = """&rsA2("Level2E")&""" AND Level3E = """&rsB1("Level3E")&""" AND Level4E = """&rsB2("Level4E")&""" "
 SQLA3= SQLA3 & "GROUP BY Level5E ORDER BY Level5E;"
 rsA3.Open SQLA3, Conn, 2, 2
 on error resume next
 Response.Write "<UL>"
 Do While NOT  rsA3.BOF AND NOT  rsA3.EOF
 response.write "<LI>"& rsA3("Level5E")&"</LI>"

 rsA3.MoveNext
 LOOP : on error goto 0
 Response.Write "</UL>"
 rsA3.Close : Set  rsA3 = Nothing


 rsB2.MoveNext
 LOOP : on error goto 0
 Response.Write "</UL>"
 rsB2.Close : Set  rsB2 = Nothing


 rsB1.MoveNext
 LOOP : on error goto 0
 Response.Write "</UL>"
 rsB1.Close : Set  rsB1 = Nothing

 

 rsA2.MoveNext
 LOOP : on error goto 0
 Response.Write "</UL>"
 rsA2.Close : Set  rsA2 = Nothing

 rsA1.MoveNext
 LOOP : on error goto 0
 Response.Write "</UL>"
 rsA1.Close : Set  rsA1 = Nothing
%>



Posted By: zMaestro
Date Posted: 07 February 2005 at 6:04am
This code worked fine, but i only have 1 problem,
I don't want it to enter the loop unless the value is not null.
i.e.
if there is a value in the filed then do this:
Set  rsB2 = Server.CreateObject("ADODB.Recordset")
SQLB2= "SELECT Level4E, COUNT(Level4E) AS majorCategories FROM Levels WHERE DUserName = '"&DUserName&"' AND Show = 'y' AND Level1E = '"&rsA1("Level1E")&"' AND Level2E = '"&rsA2("Level2E")&"' AND Level3E = '"&rsB1("Level3E")&"' "
 SQLB2= SQLB2 & "GROUP BY Level4E ORDER BY Level4E;"
 rsB2.Open SQLB2, Conn, 2, 2
the problem is that i can't select any other field when using the count, any way to get through this??


Posted By: zMaestro
Date Posted: 08 February 2005 at 12:54pm
oh.. a friend told me the way and it worked Smile
 

SQLA1= "SELECT DISTINCT Level1E FROM Levels"
Smile



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net