TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-07-2007, 04:20 AM   #1 (permalink)
The Wanderer
 
Join Date: Dec 2007
Location: united states
Posts: 16
Thanks: 7
Matt is an unknown quantity at this point
Default Categories and sub categories

A lot of people can easily do this, but I seem to be having some trouble.
With the same table, i want to be able to create categories with unlimited sub categories.
Can somebody point me to the right direction to learn about this?
Or can I have a simple function that does this to build/learn off of?
If I haven't explained this well enough, I can try better if there is confusion caused.
Thanks in advance.
Send a message via AIM to Matt Send a message via MSN to Matt Send a message via Yahoo to Matt
Matt is offline  
Reply With Quote
Old 12-07-2007, 04:26 AM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Welcome to the community Matt It's always a pleasure to see a new face! I actually described a solution to this only the other day over here. If that solution seems somewhat confusing then please do say so and I/we'll be more than happy to help you on a level that you are able to understand.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-07-2007, 04:38 AM   #3 (permalink)
The Wanderer
 
Join Date: Dec 2007
Location: united states
Posts: 16
Thanks: 7
Matt is an unknown quantity at this point
Default

Yes, that does help a little.
Let me explain

I have created following type structure

(1) Id - Integer
(2) name - Varchar
(3) parentid - Integer

Parentid will store id of parent category. If category is main category then its parentid will be ZERO.

I think this structure is correct. But i don't know that how should i display this all category.

Can you help me about what type of php loop programming i have to use?

Kindly just give me php loop programming which can display all category like this


-Root Category
--Category
---Sub Category
----Sub Sub Category

Also, thank you for the warm welcome, I just found out about this site and there seems to be some extremely good PHP programmers here that I can learn from.
Send a message via AIM to Matt Send a message via MSN to Matt Send a message via Yahoo to Matt
Matt is offline  
Reply With Quote
Old 12-07-2007, 11:25 AM   #4 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

Why is it limited to only one table? Even Wordpress uses 3 tables for categories. :|
Haris is offline  
Reply With Quote
Old 12-07-2007, 12:18 PM   #5 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

If you feel adventurous enough, have a go at the modified pre order tree traversal: http://www.sitepoint.com/article/hie...ata-database/2

Last edited by bdm : 12-07-2007 at 06:19 PM.
bdm is offline  
Reply With Quote
The Following User Says Thank You to bdm For This Useful Post:
Karl (12-07-2007)
Old 12-07-2007, 06:15 PM   #6 (permalink)
The Wanderer
 
Join Date: Dec 2007
Location: united states
Posts: 16
Thanks: 7
Matt is an unknown quantity at this point
Default

Quote:
Originally Posted by Haris View Post
Why is it limited to only one table? Even Wordpress uses 3 tables for categories. :|
I want to create a forum system, faq system, downloads, gallery, etc, and I don't want to use a table for each category, I would rather have all their categories controlled by one table, it would be a lot better than having, two or more tables for each module.


Quote:
Originally Posted by gcbdm View Post
If you feel adventurous enough, have a go at the modified pro order tree traversal: http://www.sitepoint.com/article/hie...ata-database/2
This helps, thank you, I think i'm starting to get an idea on how to do this.
Send a message via AIM to Matt Send a message via MSN to Matt Send a message via Yahoo to Matt
Matt is offline  
Reply With Quote
Old 12-07-2007, 06:23 PM   #7 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

Quote:
Originally Posted by Matt View Post
This helps, thank you, I think i'm starting to get an idea on how to do this.
Here is some other juicy information on the topic: http://dev.mysql.com/tech-resources/...ical-data.html
bdm is offline  
Reply With Quote
The Following User Says Thank You to bdm For This Useful Post:
Matt (12-07-2007)
Old 12-07-2007, 06:36 PM   #8 (permalink)
The Wanderer
 
Join Date: Dec 2007
Location: united states
Posts: 16
Thanks: 7
Matt is an unknown quantity at this point
Default

Quote:
Originally Posted by gcbdm View Post
Here is some other juicy information on the topic: http://dev.mysql.com/tech-resources/...ical-data.html
This is exactly what I needed, it has the same table structed as what I was going for. I'm just having a little trouble with the php code. Thanks for this resource though, much appreciated.
Send a message via AIM to Matt Send a message via MSN to Matt Send a message via Yahoo to Matt
Matt is offline  
Reply With Quote
Old 12-07-2007, 06:38 PM   #9 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

No problem man.

Are you going for the Adjacency List Model?
bdm is offline  
Reply With Quote
Old 12-07-2007, 06:41 PM   #10 (permalink)
The Wanderer
 
Join Date: Dec 2007
Location: united states
Posts: 16
Thanks: 7
Matt is an unknown quantity at this point
Default

Yes I am going for the Adjacency List Model.
With using their provided table structure I want to make a tree, i think from then on I can figure out the rest, but I can't form it into a tree.
Send a message via AIM to Matt Send a message via MSN to Matt Send a message via Yahoo to Matt
Matt is offline  
Reply With Quote
Old 12-07-2007, 06:46 PM   #11 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default

What's your question exactly?
bdm is offline  
Reply With Quote
Old 12-08-2007, 10:39 PM   #12 (permalink)
The Wanderer
 
Join Date: Dec 2007
Location: united states
Posts: 16
Thanks: 7
Matt is an unknown quantity at this point
Default

What the loop should look like to display categories and sub categories in a tree with one table called categories

i'm still troubled on making the loop, i tried on my own and i still can't do it.

Last edited by Matt : 12-11-2007 at 08:01 PM.
Send a message via AIM to Matt Send a message via MSN to Matt Send a message via Yahoo to Matt
Matt is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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


All times are GMT. The time now is 06:17 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design