Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependent Drop down in Grocery CRUD (CodeIgniter)

I stucked in a Problem When Playing with Drop Downs.I tried to use this http://www.grocerycrud.com/forums/topic/1087-updated-24112012-dependent-dropdown-library/

But actually my requirement is quite different. I have a table fwld_products in which i am adding all other table's categories, from

fwld_cat_main (main Category's ID),

fwld_cat_sub1 (sub1 Category's id)

fwld_cat_sub2 (sub2 Category's id)

fwld_cat_sub3 (sub3 Category's id)

I want to Display Dropdown in such a way, when user Selects main Category, the Drop Down Appear (sub1) Having Data related to main category and when sub1 selected drop down appear (sub2) showing data related to sub1, and sub2 selected and drop down appear(sub3) to show data related to Drop down (sub2).

When submitted Finnally data inserted to [fwld_products].

Here I am attaching ERD, and result as well.

enter image description hereenter image description here

Please help

like image 567
Engr Saddam Zardari Avatar asked Nov 02 '22 03:11

Engr Saddam Zardari


1 Answers

Hold on, it seems that DB structure of your categories table needs to be improved. What I suggest is that you follow footprints from some of the popular CMS like Opencart. It will give you a great sense to accomplish your task. You can easily optimize your DB by using just one "category" table (instead of main, sub1, sub2, and sub3 category tables) like this:

category

For category names, description, and meta keywords etc you can create this table "category_description":

category_description

Finally to assign categories to the products you can simply create another table "product_to_category":

product_to_category

In this way you can easily manage your data in DB and you can now easily tackle your situation using Codeigniter and Grocerycrud.

like image 126
Ali Avatar answered Nov 08 '22 09:11

Ali