categories

J

jeef

Im setting up a database driving store running off of a sql database
and asp.
I want to have categories with subcategories. That way a customer can
borrow down through my site to buy a product.
For example: going to a grocery store your looking for cake.
categories would be Groceries -> Bakery -> Cake -> Chocolate -> Happy
Birthday or
Groceries -> bakery -> Cake -> White -> Congratulations

How should i setup the database and with asp how would i list the
categories so that whenever the customer comes to my site it would say
Bakery Snacks
Cake Chips
Donuts Pretzels
Rolls Oreos


Dairy
Milk
Cheese
Yogurt
 
C

Chris Hohmann

jeef said:
Im setting up a database driving store running off of a sql database
and asp.
I want to have categories with subcategories. That way a customer can
borrow down through my site to buy a product.
For example: going to a grocery store your looking for cake.
categories would be Groceries -> Bakery -> Cake -> Chocolate -> Happy
Birthday or
Groceries -> bakery -> Cake -> White -> Congratulations

How should i setup the database and with asp how would i list the
categories so that whenever the customer comes to my site it would say
Bakery Snacks
Cake Chips
Donuts Pretzels
Rolls Oreos


Dairy
Milk
Cheese
Yogurt

What database/version? If it's MS SQL Server, there's an article in
Books Online (BOL) under the heading "Expanding Hierarchies" that does
what you're looking for.

HTH
-Chris Hohmann
 
N

Navid

hi,
you can use this ...

tbl_categories
=======================================
id(autonumber),name(text 255),up_cat_id(Number - which is the ID of up
Category)
=======================================
<%
cat=request("cat") ' current category
strsql="Select * From tbl_categories where up_cat_id=" & cat & " order by
id"
objrs.open strsql, objconn,3,1
count=objrs.recordcount\2+1
if count=objrs.recordcount/2+1 then count=count-1
%>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:
collapse; font-size:8pt" bordercolor="#111111" width="100%"
id="AutoNumber1">
<tr>
<td width="50%" valign="top">
<%
for i=1 to count
if not objrs.eof then
strsql1="Select * From tbl_categories where up_cat_id=" & objrs("id") & "
order by id"
objrs1.open strsql1, objconn,3,1
%>
<p><a href="./?cat=<%=objrs("id")%>" style="text-decoration:
none"><b><%=objrs("name")%></b></a><br>
<%
do while not objrs1.eof
%>
-<a href="./?cat=<%=objrs1("id")%>" style="text-decoration: none">
<%=objrs1("name")%></a><br>
<%
objrs1.movenext
loop
objrs1.close
objrs.movenext
end if
next
%>
</td><td width="50%" valign="top">
<%
for i=1 to count
if not objrs.eof then
strsql1="Select * From tbl_categories where up_cat_id=" & objrs("id") & "
order by id"
objrs1.open strsql1, objconn,3,1
%>
<p><a href="./?cat=<%=objrs("id")%>" style="text-decoration:
none"><b><%=objrs("name")%></b></a><br>
<%
do while not objrs1.eof
%>
-<a href="./?cat=<%=objrs1("id")%>" style="text-decoration: none">
<%=objrs1("name")%></a><br>
<%
objrs1.movenext
loop
objrs1.close
objrs.movenext
end if
next
%>
</td> </tr>

</table>

===============================================
Nav!d
Free Weblog Management System @
http://www.asp-rider.com/
(But in Persian)
===============================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top