#
#
# artur #2014-09-27 00:01:23
PHP
# artur #, 2014-09-27 00:01:23

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

1 answer(s)
X
xmoonlight, 2014-09-27
@passshift

so id))))
id | name | parent_id | display_after_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question