display child filed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Think Pink
Forum Contributor
Posts: 106
Joined: Mon Aug 02, 2004 3:29 pm

display child filed

Post by Think Pink »

Hello,
I have a question about displaying a table in a recursive way. Not shure if I express my self corectly so sorry for that and for my bad english, but I hope you will understand

for example I have the folloeing table:

[table]
id int(5) auto_increment
category_name varchar(15)
parent_id int(5)

and this is tha data it contains
1 | Top category | 0
2 | Cars | 1
3 | Old cars | 2
4 | New cars | 2
5 | Computers | 1
6 | Used computers | 5
7 | Used Monitors | 6


This should be displayed like this in html
Cars
> Old cars
> New cars
Computers
> Used Computers
>> Used monitors

Any ideeas how could I do that?
Thx
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

Look at these pages
how to create the array in which you' ll put the categories and subcategories
http://www.phpwebcommerce.com/source/li ... ctions.php
how to display them on the page
http://www.phpwebcommerce.com/shop-browse-category.php
Good luck!
User avatar
Think Pink
Forum Contributor
Posts: 106
Joined: Mon Aug 02, 2004 3:29 pm

Post by Think Pink »

thank you. I'll take a look
Post Reply