Data table design method for PHP unlimited classification (1) (pictures, text + video)

藏色散人
Release: 2019-07-12 17:57:52
Original
6305 people have browsed it

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.

Data table design method for PHP unlimited classification (1) (pictures, text + video)

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!

Data table design method for PHP unlimited classification (1) (pictures, text + video)

Add some information to the new table.

Data table design method for PHP unlimited classification (1) (pictures, text + video)

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);
Copy after login

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:

Data table design method for PHP unlimited classification (1) (pictures, text + video)

As shown in the figure, we have successfully created a classification data table.


Note: pid is used to store the id of the upper level category!

This article is about the creation of classified data tables in

PHP 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 website

PHP 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!