/    Sign up×
Community /Pin to ProfileBookmark

how can i display my database records in tree format

i have a product table ..corresponding to that i have categories and subcategories.my project flow is i am able to insert the product based on the categories..i need to display my categories and subcategories in the tree foramt.for categories i have one table where i have category_id as a primary key and subcategories i have one more table where category_id i used as a reference.everything is working fine.but while coming to dispaly i am not getting how can i do the tree structure.i knw i need to maintain a parent child relationship but implementaion i dnt knw..
As soon as i click the categories i should get all the subcategories.please help me regarding this.

Thanks Advance

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiDec 21.2009 — I lean towards using the nested set model described here in this situation.
Copy linkTweet thisAlerts:
@prathikanoeauthorDec 21.2009 — thanks for ur reply..but how can i insert the parent id in the category table that i am not getting.i am able to get all the data as it is dynamic i cant specify a single condition.regarding the display i am not gettng how i should proceed..whether i need to use ajax upon onclick event or what.pls suggest me..i searched alot but dint got any result
×

Success!

Help @prathikanoe spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...