Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Don’t show the subcategories
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Don’t show the subcategories

 Post Reply Post Reply
Author
Lucent View Drop Down
Groupie
Groupie


Joined: 06 June 2003
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lucent Quote  Post ReplyReply Direct Link To This Post Topic: Don’t show the subcategories
    Posted: 19 August 2003 at 2:16pm

Hi, I have this code I'm trying to modify, but I just cant seem to find a way to get around it , hope someone can help here. 

What I have is part of the code that does the drop down menu of all my categories & subcategories.  I need it just to show only level 1 of my catgories in the drop down menu.

What it shows in the drop down menu right now

Bag-backpack

Bag-clutch

Shoes-sandals

Shoes-boosts

I want it to show only

Bag

Shoes

===========================================

Here is the code I have

=============================================

<% ' get leaf categories from db
mySQL="SELECT idcategory,categoryDesc FROM categories WHERE idparentcategory=1 AND idCategory>1 AND iBTOhide=0 ORDER BY categoryDesc"
set rs=conntemp.execute(mySQL)
%>
<select name="idcategory">
<option value='0'>
<%response.write dictLanguage.Item(Session("language")&"_advSrca_4")%>
</option>
<% Do While NOT rs.EOF
'check to see if catagory has subcategories
strSQL="SELECT idcategory,categoryDesc FROM categories WHERE idParentCategory="& rs("idCategory")
set rs2=server.CreateObject("ADODB.Recordset")
set rs2=conntemp.execute(strSQL)
if rs2.eof then
subVar="1"
Else
do while NOT rs2.eof
strSQL="SELECT idcategory,categoryDesc FROM categories WHERE idCategory="& rs2("idCategory")
dim rs3
set rs3=server.CreateObject("ADODB.Recordset")
set rs3=conntemp.execute(strSQL)
'check to see if catagory has subcategories
strSQL="SELECT idcategory,categoryDesc FROM categories WHERE idParentCategory="& rs3("idcategory")
dim rs4
set rs4=server.CreateObject("ADODB.Recordset")
set rs4=conntemp.execute(strSQL)
if rs4.eof then
subVar3="1"
Else
do while NOT rs4.eof
strSQL="SELECT idcategory,categoryDesc FROM categories WHERE idCategory="& rs4("idCategory")
dim rs5
set rs5=server.CreateObject("ADODB.Recordset")
set rs5=conntemp.execute(strSQL)
'check to see if catagory has subcategories
strSQL="SELECT idcategory,categoryDesc FROM categories WHERE idParentCategory="& rs5("idcategory")
dim rs6
set rs6=server.CreateObject("ADODB.Recordset")
set rs6=conntemp.execute(strSQL)
if rs6.eof then
subVar5="1"
Else
do while NOT rs6.eof
strSQL="SELECT idcategory,categoryDesc FROM categories WHERE idCategory="& rs6("idCategory")
dim rs7
set rs7=server.CreateObject("ADODB.Recordset")
set rs7=conntemp.execute(strSQL)%>
<option value='<%=rs7("idCategory")%>'> <%= rs("categoryDesc") %>
- <%= rs3("categoryDesc") %> - <%= rs5("categoryDesc") %> - <%= rs7("categoryDesc") %></option>
<% rs6.MoveNext
Loop
set rs7=nothing %>
<% End If 'rs6.eof %>
<% If subVar5<>"1" then %>
<% Else %>
<option value='<%=rs5("idCategory")%>'><%= rs("categoryDesc") %>
- <%= rs3("categoryDesc") %> - <%= rs5("categoryDesc") %></option>
<% end if %>
<% rs4.MoveNext
Loop
set rs5=nothing %>
<% End If 'rs4.eof %>
<% If subVar3<>"1" then %>
<% Else %>
<option value='<%=rs3("idCategory")%>'><%= rs("categoryDesc") %>
- <%= rs3("categoryDesc") %></option>
<% end If %>
<% rs2.MoveNext
Loop
set rs3=nothing %>
<% End If 'rs2.eof %>
<% If subVar<>"1" then %>
<% Else %>
<option value='<%=rs("idCategory")%>'><%= rs("categoryDesc") %></option>
<% End If %>
<% subVar="0"
subVar3="0"
subVar5="0"
rs.MoveNext
Loop
set rs1=nothing %>
</select>
<input type="hidden" name="idSupplier" value="10">
</font></td>
</tr>

==============================================

Thanks in advance!!

 

Back to Top
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post Posted: 24 August 2003 at 1:29pm

Is it possible to see it in action, so we can see what exactly you are looking at.

Back to Top
peterm View Drop Down
Newbie
Newbie


Joined: 24 November 2002
Location: United Kingdom
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote peterm Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2003 at 5:06am

Do you only have two levels of categories? e.g. main category and sub category?

If so, why not have the categories table like this:

CategoryId  Name  OwnerId
--------------------------
1           ;     Shoes      0
2           ;     Bag         0
3           ;     Backpack 2
4           ;     Clutch     2
5           ;     Sandels   1
6           ;     Boosts     1

Then if you only want to display the main categories use the following SQL:

mySQL = "SELECT CategoryId, Name FROM Categories WHERE OwnerId = 0 ORDER BY Name"

This will give you a list of Bag and Shoes, as intended.


Then you can display the subcategories on the following page by retreiving the CategoryId from the form collection and doing a SQL query like

mySQL = "SELECT CategoryId, Name FROM Categories WHERE OwnerId = " & Request.Form("CategoryId")

I'm not if thats what you want - but your ASP file seems over-complicated and very hard to understand - sorry!

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.