arunpatal Posted December 31, 2012 Share Posted December 31, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/272538-sub_category/ Share on other sites More sharing options...
arunpatal Posted December 31, 2012 Author Share Posted December 31, 2012 I think its confusing the way i explained.... I just need to make sub_category please show me some way to make it. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/272538-sub_category/#findComment-1402298 Share on other sites More sharing options...
Muddy_Funster Posted December 31, 2012 Share Posted December 31, 2012 what do you meen make it? what exactly are you having an issue with? let's see what code you have already. Quote Link to comment https://forums.phpfreaks.com/topic/272538-sub_category/#findComment-1402301 Share on other sites More sharing options...
Barand Posted December 31, 2012 Share Posted December 31, 2012 (edited) 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 December 31, 2012 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/272538-sub_category/#findComment-1402320 Share on other sites More sharing options...
arunpatal Posted December 31, 2012 Author Share Posted December 31, 2012 (edited) 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 December 31, 2012 by arunpatal Quote Link to comment https://forums.phpfreaks.com/topic/272538-sub_category/#findComment-1402350 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.