The website has three levels of columns: one topic type table and one article table topic type: idpid (id and parent layer id) Article type: idtyid (id and topic id) example: {code ...} how can I display all articles in football in sports ?? How should I read it? This website is divided into three levels: a column type table and an article table.
Topic type: id pid (id and parent layer id)
Article type: id tyid (id and topic id)
For example:
Sports id = 1 pid = 0 ball game id = 10 pid = 1 football id = 20 pid = 10 football article id = casual tyid = 20
How can I display all articles in football in sports ?? How should I read it?
I am a beginner in php and mysql. Hope you can give me some advice! Please do not randomly add join SQL concatenation or recursive reading! Thank you!
Reply content:
The website has three levels of columns: one column type table and one article table.
Topic type: id pid (id and parent layer id)
Article type: id tyid (id and topic id)
For example:
Sports id = 1 pid = 0 ball game id = 10 pid = 1 football id = 20 pid = 10 football article id = casual tyid = 20
How can I display all articles in football in sports ?? How should I read it?
I am a beginner in php and mysql. Hope you can give me some advice! Please do not randomly add join SQL concatenation or recursive reading! Thank you!
First, write a recursive function to query the child directory id, and then query the article with the directory id as the query condition.
There are many ways to read data. I will give you a more convenient query method, but you need to modify the table structure.
Add a level and top_id
select * from table where top_id = 1 and level = 3
In this way, all the three-level categories are queried and the corresponding articles are queried by category.
The advantage is that two more fields need to be maintained in the background management (of course, the specific fields need to be processed according to your business logic)