How do you read the data here?
Second level: Show: Category category_id Category_name (rank two)
Level Three: Indicates: Subcategory subcategory_id Subcategory_name (Level three name) Subcategory_category (with Category table ID management)
Now I'm doing it.
Identify the second level of data
$result = Select category_id,category_name from category; Result of data return
Identify the third level of data
foreach ($result as $k = = $v) {
$result 2[]=select subcategory_name from subcategory where subcategory_category= $v [' category_id '] return your results;
}
Is that good? The database has been accessed multiple times
Reply to discussion (solution)
Why can't you?
If you want to read subcategory only once, you can read out all the data of subcategory
Fill in the $result.
Multi-level recursion, that's it.
This allows the database to operate frequently, and SQL executes multiple
Are you worried about the database will be tired?