473,324 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Need Help w/ Unlimited depth categories

I'm working on writing a website which I need to have lists of
products listed in categories and subcategories, and need to keep
track of whats in the tree. Like how many products from the root all
the way down through the subcategories. I was thinking maybe in each
category it would have a field which lists all the root categories. I
hope this is a good explanation... it's kinda hard to explain I guess.
I figure there were probably some websites out there with methods or
something... Any help on this would be great.... Or a direction I can
do some researching..

Thanks

Troy
Jul 17 '05 #1
2 3505
Hi Troy!

On 4 Jan 2004 16:18:16 -0800, dj********@yahoo.com (Troy Lynch) wrote:
I'm working on writing a website which I need to have lists of
products listed in categories and subcategories, and need to keep
track of whats in the tree. Like how many products from the root all
the way down through the subcategories. I was thinking maybe in each
category it would have a field which lists all the root categories. I
hope this is a good explanation... it's kinda hard to explain I guess.
I figure there were probably some websites out there with methods or
something... Any help on this would be great.... Or a direction I can
do some researching..


There should be heaps. Have a search for "tree php adjacent" or "tree
php nested set". These are the two most common methods.

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #2
Greetings.

One possibility is to have a field like "mother_category" in the
categories list. Each category would have a "mother", referred by it's
record ID or something like that. The category with mother_category=0
would be the root.

To count the products in a branch, create a recursive function that
adds the produtcs in every sub-category of the category you want to
start.

Something like:
Table categories:
id
category
mother_category <- categories.id

Table products:
id
cat_id <- categories.id
product

The function:
Parameter: top_id (id of the top category you want to consider)
How it works:
count the number of products with cat_id = top_id;
get the list of the sub-categories of the top_id category;
for each sub-category, it calls itself and adds the result to the
sum of products
Returns: the sum of products of that branch

Hope this helps,
Joaquim Amado Lopes

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brian Murphy | last post by:
<?php /* I need your help. I'd be very thankfull if write me this script.I need a script that displays a list of categories and subcategories like this: <select name="category"> <option...
1
by: Bola | last post by:
Hi there. U have table structure shown here: category (Int - AutoIncrement) parent_category(Int) Title(string) 1 0 HOME PAGE 2 ...
5
by: Travis Pupkin | last post by:
Hey, I've done a number of product catalogs/galleries with one or two category levels (Category > Subcategory). The straightforward way to do this, of course, is to use database fields for...
4
by: Jani Yusef | last post by:
I want to create a tree of processes. The depth of the tree is given by the variable depth and the number of processes started by each node is given by the variable numberOfProcesses. Is the...
4
by: Steve Klett | last post by:
(I posted this in ADO group, but I think this group will be better) Hi- I need to develop an FAQ section for our website. We would like to break up the FAQ by products, then categories with...
2
by: tagnum | last post by:
I have written a program for unlimited categories depth, which is in use for few ecommerce websites. Like many others, I used one SQL table to store the category relation (or the tree structure)....
25
by: vikram Bhuskute | last post by:
I have plans to train some students for C in coming weeks. I am badly looking for C programming assignments fot them. Need 1) lots of them per topiic 2) Should be doable for beginners thanks...
2
klarae99
by: klarae99 | last post by:
Hello, I am working in Access 2003 on an inventory database. Right now I am working on a report which will be used to fill in forms that our state requires periodically to collect taxes. Right...
9
by: pereges | last post by:
Hello I need some ideas for designing a recursive function for my ray tracing program. The idea behind ray tracing is to follow the electromagnetic rays from the source, as they hit the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.