Current location: Hot Scripts Forums » Programming Languages » PHP » Categories -> Sub-Cat -> SubSub-Cat


Categories -> Sub-Cat -> SubSub-Cat

Reply
  #1 (permalink)  
Old 03-16-09, 04:11 PM
davestar057 davestar057 is offline
Wannabe Coder
 
Join Date: Dec 2007
Posts: 115
Thanks: 1
Thanked 1 Time in 1 Post
Categories -> Sub-Cat -> SubSub-Cat

Hi,

Can somebody PLEASE help me out here. I have searched high, low and inbetween for a solution to this, but I keep going around in circles...

Basically I want to creat a 3 layer navigation for products on my site:

For example

DRINKS -> FIZZY -> COCACOLA

I have heard that you can do something along the lines of

cat_id
cat_name
parent_id

so if 'DRINKS' has a 'Cat_id' of '5' then for any type of 'subcat' you want under drinkins would have a 'Parent_id' of '5'.....and if it was to be a 'main cat...then you would set that to 0.

okay....that makes sense...but what about if I want sub-sub-cats????? I could carry on in the same way...but then it becomes VERY messy and confusing when creating this!?!?

Please can you guys let me know if this is how you do it?? or if there are other ways out there?

Do you perhaps use multiple tables? Or does that take up too much processing time etc....??

I have read many things and each vary from VERY VERY crazy technical...to the simple version (if not using too many products) above.

PLEASE PLEASE PLEASE can somebody help put my mind at rest and either let me know how YOU do it....or show me some examples of how it can be done (which work)


This would help ALOT! Many thanks guys, this forum rocks.

David
Reply With Quote
  #2 (permalink)  
Old 03-17-09, 02:22 AM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
It sounds like you're trying set up a hierarchical (tree) data structure.

http://www.sitepoint.com/article/hie...data-database/
http://www.intelligententerprise.com...=145525%5D

Last edited by dgreenhouse; 03-17-09 at 02:32 AM.
Reply With Quote
  #3 (permalink)  
Old 03-17-09, 08:47 AM
davestar057 davestar057 is offline
Wannabe Coder
 
Join Date: Dec 2007
Posts: 115
Thanks: 1
Thanked 1 Time in 1 Post
Okay, so I have read these articles and it makes sense....however I am still confused as to how to apply this to a CSS menu navigation system in a website...which then displays the correct products releating to where you are on the Nav??
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Indenting Sub Categories Lionheart PHP 2 10-04-04 12:06 AM


All times are GMT -5. The time now is 08:30 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.