Answer the question
In order to leave comments, you need to log in
How to organize sorting of product categories with different levels of nesting?
Hello.
I am writing a product catalog in PHP, the categories and subcategories themselves are stored in one MySQL table, figuratively the structure is as follows: id | name | parrent_id
parrent_id indicates nesting and contains the ID of the main category, everything is simple and clear here.
Initially, when displaying categories, you can sort in alphabetical order, but you may need to place the "Books" category above the "Magazines" category, in what form and how to properly store the sort order?
There is an absurd idea to add a sort column and indicate the serial number in it, the absurdity is that it will be impossible to keep track of the sorting number of other categories.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question