Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

directory structure

Status
Not open for further replies.

vlitim

Programmer
Sep 2, 2000
393
GB
I have a category table

id name parent

where parent is which category the currect cat is under. Then I have products table

id name catid

where catid links to the category table.

What I need to do is go down each category display any products along the way.


cat
subcat
subcat
subcat
products
subcat
products

and so on. How do I go about doing this, I can do it for first level subcats but don't understand how to do it recursivley.

Any help would be much appreciated as I am completly stuck on this one!

Cheers

Tim

 
Hi,

Lets do it using the easiest way! I'm supposing that the main category has no parent.
1. Ask DB for those records that have no parent - main category.
2. For each one try to see if they have sub categories, search for categories whose parent is the first one, and so on.
3. When reach to a categoriy which don't have childs, list its products.
I think there is one more problem. Each category can have sub categories and products.
I've never did this, but I hope this works. The best way to do this is using a function.
Code:
function child(parentID)
  (open database)
  (RS is the recordset for all categories whose parent is parentID)
  if (RS.EOF = RS.BOF And RS.EOF = true) then
    ' No category returned so there are no children (sub)
    child = ""
    exit function
  end if
  do until RS.EOF
    (display category name)
    child(RS("id"))
    (search DB for products od this category and display then)
    RS.MoveNext
   loop
   child = ""
end function
As I said, I don't know if this is going to work... I hope it does

Regards,
Luís Silva
 
sir i want to know how should i have to create

an array user name in application or by session to show in frame page like yahoo messenger chat.

please help me to load the no peoples to show on window
("that they r online")


by that way i have to go for private caht by clicking the members which i prefered. i have done all the things,but i have to catch up in array(name list of members)
& to go haw to private chat,when i entered chat by different system it is poening onother paper,i want to know to show the array list of members.

in an same window.

thank u
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top