Click to See Complete Forum and Search --> : Urgent Help needed to Add Unlimited Categories and Sub Categories


w_developer
07-18-2007, 04:58 PM
Hello,

I am trying to figure out for a long long time how can I make a page where I provide user to add categories like fun, entertainment etc and then he can add any sub-category to any of these categories and so on.
For eg >
Level 1 Fun Christmas Entertainment
Level 2 Christmas-> American Christmas
Level 2 Christmas-> European Christmas
Level 3 Christmas-> American Christmas-> New York Christmas
Level 3 Christmas-> American Christmas-> Chicago Christmas
and so on and all this data gets stored in a database.

Now I understood that I need a table categories in database with parameters
cat_id,cat_name and parent_id to do this and have multiple categories.

I am very new to all this stuff and have no clue how to start :(
What to display on main page, how to display categories and how to provide user with an option to add sub categories.

I would be very thankful if someone who has done similar thing can help and provide me with some sample code of similar stuff.
I need help very urgently.

Please reply sooon.

Thanks

w_developer
07-18-2007, 05:04 PM
Hello,
(I want to use PHP/HTML interface and have a MySQL database)
I am trying to figure out for a long long time how can I make a page where I provide user to add categories like fun, entertainment etc and then he can add any sub-category to any of these categories and so on.
For eg >
Level 1 Fun Christmas Entertainment
Level 2 Christmas-> American Christmas
Level 2 Christmas-> European Christmas
Level 3 Christmas-> American Christmas-> New York Christmas
Level 3 Christmas-> American Christmas-> Chicago Christmas
and so on and all this data gets stored in a database.

Now I understood that I need a table categories in database with parameters
cat_id,cat_name and parent_id to do this and have multiple categories.

I am very new to all this stuff and have no clue how to start
What to display on main page, how to display categories and how to provide user with an option to add sub categories.

I would be very thankful if someone who has done similar thing can help and provide me with some sample code of similar stuff.
I need help very urgently.

Please reply sooon.

Thanks

otuatail
07-18-2007, 05:25 PM
you need something lik
ALTER TABLE Categories ADD Christmas varchar(30) default NULL

Desmond

bubbisthedog
07-18-2007, 11:36 PM
This is merely an idea of such a DB structure --perhaps just the beginning of it; you're asking for quite a lot actually, if I'm understanding you correctly. All first fields are primary keys and are expected to be auto incremented.

COUNTRIES

COY_ID | COY_DESC
---------------------------
1 | America
2 | England
3 | Germany

CITIES

CIT_ID | CIT_DESC
---------------------------
1 | New York
2 | Berlin
3 | Chicago
4 | London

CONTINENTS

CON_ID | CON_DESC
---------------------------
1 | North America
2 | Europe

CONTINENT_COUNTRIES

CCO_ID | COY_ID | CON_ID
----------------------------------------
1 | 2 | 2
2 | 1 | 1
3 | 3 | 2

COUNTRY_CITIES

CCT_ID | CIT_ID | COY_ID
----------------------------------------
1 | 3 | 1
2 | 4 | 2

HOLIDAYS

HOL_ID | HOL_DESC
---------------------------
1 | Christmas
2 | Halloween

ENTERTAINMENT

ENT_ID | ENT_DESC
---------------------------
1 | Trick or Treat
2 | Meet Santa

CITY_HOLIDAY_ENTERTAINMENT

CHO_ID | CIT_ID | HOL_ID | ENT_ID
----------------------------------------------------
1 | 1 | 1 | 2
2 | 3 | 2 | 1

This DB structure would be totally normalized and allow for queries like 'What entertainment is available in New York on Christmas?'

w_developer
07-19-2007, 08:05 AM
hey what kind of reply was that? It did not help in any way :(

I need to know how to display main page, what items to display and how back end will work so that categories get stored in one table in mysql databse and sub categories in another table.

One more question is
I have a table catgeories with
cat_id, cat_name and parent_id
and another table sub categories with
cat_id,subcat_id,subcat_name

Now I have a drop down with all categories as options on add sub category page.
If the user selects say category 1 from the drop down box and types in sub category name 'test' and clicks add sub category,
1. how to get which category was selected from the option box and send it to sub categories table.
2. cat_id is auto increment and so is subcat_id and parent_id is for knowing which level it is. What should be default value of parent_id ?

Please explain how all this works

thanks

w_developer
07-19-2007, 08:10 AM
Okay this is DB structure,
Thnx for that
how will the user enter this data and how it will be stored in different tables in the databse?

Please reply and help me out with this.

bubbisthedog
07-19-2007, 08:34 AM
I've presented you with a potential DB structure; now you need to present to me and yourself (mainly) the requirements for your project (actually that should come first, but, oh well...). What exactly are you wanting to do here? How do you want your interface to function? There are too many questions for you to ask and answer before delving into the programming side of things.

Do you have any experience with coding/ER modeling/MySQL/PHP? If not, I suggest taking advantage of the plethora of tutorials on the Web for SQL and PHP.

LeeU
07-19-2007, 10:15 AM
Please don't cross post. The other has been combined with this one.