Home > php教程 > PHP开发 > ThinkPHP usage experience sharing-ThinkPHP + Ajax realizes 2-level linkage drop-down menu

ThinkPHP usage experience sharing-ThinkPHP + Ajax realizes 2-level linkage drop-down menu

高洛峰
Release: 2016-12-30 09:52:24
Original
1543 people have browsed it

The first is the design of the database. The classification table is called cate.

What I am doing is the second-level linkage of classified data. The fields required for the data are: id, name (Chinese name), pid (parent id).

Parent id Settings: If the data does not have an upper level, the parent id is 0. If there is an upper level, the parent id is the id of the upper level.

After the database has content, you can start writing code to implement secondary linkage.

First get all the data with pid 0 in the background php, save it to $cate, and then use a foreach loop to output it in the first layer's