Jump to content

Sub_Category


arunpatal

Recommended Posts

hi,

 

I want to make subcategory for items........ but i am lost ??????

 

lets say i have 3 tables.....

 

1-item 2-category 3-subcategory

 

 

 

now item table have

 

id (ai & pk)

 

item_name (copmuter)

 

category (2 (this is id of category from category table) )

 

subcategory (4 (this is id of subcategory from subcategory table) )

 

 

now category table have

 

id (ai & pk)

 

category_name

 

subcategory_name

 

now subcategory table have

 

id (ai & pk)

 

subcategory_name

 

 

now i want that when i add item

it ask for category and when i select category

it shows me sub category of that category.

 

I don't know if there is some easy way to make subcategory???

if yes then please explain....

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/272538-sub_category/
Share on other sites

Your items would only need the subcat id, you get the category from the subcat

 

category..sub_cat...item

--------..--------..--------

cat_id....subcatid..item_id

descrip...descrip...descrip

..........cat_id....subcatid

 

Alternatively you can store the subcats and categories in a single table. Add a parent_id field. Categories will have 0 (or NULL) in this field but subcats willl contain the id of their parent category

Link to comment
https://forums.phpfreaks.com/topic/272538-sub_category/#findComment-1402320
Share on other sites

Your items would only need the subcat id, you get the category from the subcat

 

category..sub_cat...item

--------..--------..--------

cat_id....subcatid..item_id

descrip...descrip...descrip

..........cat_id....subcatid

 

Alternatively you can store the subcats and categories in a single table. Add a parent_id field. Categories will have 0 (or NULL) in this field but subcats willl contain the id of their parent category

 

Oh.... this should work....

 

I make like this :)

Thanks

Link to comment
https://forums.phpfreaks.com/topic/272538-sub_category/#findComment-1402350
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.