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

Edited by Barand
Link to comment
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

Edited by arunpatal
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.