Home > Article > Daily Programming > Data table design method for PHP unlimited classification (1) (pictures, text + video)
For PHP beginners, PHP infinite classification is a relatively difficult knowledge point.
Before introducing the knowledge points in this article, everyone needs to understand what recursion is? How to implement recursive sorting in [PHP? 】In this article, we have introduced it in detail. Friends in need can refer to it first.
PHP Unlimited Classification As the name suggests, it is an infinite level of classification. There are also examples of various classifications in daily life, such as article classification, film and television classification, and province, city, county, etc.
So in the actual project development process, PHP unlimited classification must be completed in conjunction with the database.
Let’s use a simple example to introduce the design of the data table in PHP unlimited classification and the method of connecting to mysql:
First open the Navicat database Management tool, connect to the database, here we are creating a new table under the php database. Then in the blank table, add the corresponding fields. As shown below, the table name is sort. And the three fields id, title, and pid were added respectively.The id and pid are required fields!
Add some information to the new table. Then a simple classification data table information has been created. Next we use PHP to connect to this data table and test the data in the table below. The code is as follows:<?php $host = "127.0.0.1"; $user = "root"; $password = "root"; $dbName = "php"; $link = mysqli_connect($host, $user, $password, $dbName); mysql_query($link,"select * from sort"); $row=mysqli_fetch_assoc($res); var_dump($row);In the above code, we connect to the database and query a piece of data in the sort table through the
mysql_fetch_assoc test. The results are as follows:
Note: pid is used to store the id of the upper level category!
This article is about the creation of classified data tables inPHP unlimited classification and the mysql connection operation methodIntroduction, in the next article, we will combine the data examples of this article and continue Let me introduce to you the specific implementation method of unlimited classification in PHP!
If you want to know more about PHP, you can follow the PHP Chinese websitePHP Video Tutorial, everyone is welcome to refer to and learn!
The above is the detailed content of Data table design method for PHP unlimited classification (1) (pictures, text + video). For more information, please follow other related articles on the PHP Chinese website!