categories

Discussion in 'ASP General' started by jeef, Nov 21, 2003.

  1. jeef

    jeef Guest

    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
     
    jeef, Nov 21, 2003
    #1
    1. Advertising

  2. "jeef" <> wrote in message
    news:...
    > 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
     
    Chris Hohmann, Nov 21, 2003
    #2
    1. Advertising

  3. jeef

    Navid Guest

    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)
    ===============================================

    "Chris Hohmann" <> wrote in message
    news:...
    > "jeef" <> wrote in message
    > news:...
    > > 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
    >
    >
     
    Navid, Nov 21, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neil McGuigan

    managing hierarchical data - categories

    Neil McGuigan, Mar 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    398
    \(Laurent Jordi\)
    Mar 6, 2004
  2. Chad A. Beckner

    ASP .NET Categories/(Count) Question

    Chad A. Beckner, Jun 16, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    597
    Chad A. Beckner
    Jun 16, 2004
  3. Frank Bishop

    Ecommerce Sub Categories

    Frank Bishop, Jan 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    342
    Frank Bishop
    Jan 21, 2005
  4. Øyvind Isaksen

    List categories AND records at once...

    Øyvind Isaksen, Oct 16, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    370
    Patrick.O.Ige
    Oct 17, 2005
  5. Replies:
    3
    Views:
    435
    Andy Dingley
    Feb 22, 2006
Loading...

Share This Page