Hello. There are two tables
Categories and subcategories.
How to display categories with the right subcategories. Relationship between tables by id categories.
I want to understand the algoritm, how do people implement such a menu through the base?
Hello. There are two tables
Categories and subcategories.
How to display categories with the right subcategories. Relationship between tables by id categories.
I want to understand the algoritm, how do people implement such a menu through the base?
And so! Hmm cool! And how to work with an array? I would just have an algorithm and not a code!
Well, look, if you use the structure suggested by @andreyqin , then you can take all the fields from the database and sort by parent_id. Thus, you will get these data
id | parent_id | name 1 | 1 | ΠΠΎΠ²ΠΎΡΡΠΈ 2 | 1 | ΠΠΎΠ»ΠΈΡΠΈΠΊΠ° 3 | 2 | ΠΠΊΠΎΠ½ΠΎΠΌΠΈΠΊΠ° And you can run through this array and generate views for them.
Alternatively, it is possible to group the result from the database according to the necessary criteria and to get an output data associative array.
Source: https://ru.stackoverflow.com/questions/331247/
All Articles