Home>Article>Backend Development> How to query the number in php mysql

How to query the number in php mysql

藏色散人
藏色散人 Original
2022-10-21 18:08:27 1880browse

php Mysql query number method: 1. Create a user table in the mysql database and insert three pieces of data into the table; 2. Connect to the mysql database and use mysqli_select_db to select the database to be operated; 3. , use the mysqli_query function to execute the sql statement; 4. Use the mysqli_num_rows function to obtain the number of records in the previous result set, and use echo to output it.

How to query the number in php mysql

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

php How to query the number of result sets in mysql?

In the mysql database, create a user table and insert three pieces of data into the table for testing.

How to query the number in php mysql

Create a test.php file, and within the file, use the header() method to set the encoding format of the page to utf-8.

How to query the number in php mysql

In the test.php file, connect to the mysql database and use mysqli_select_db to select the database to operate.

How to query the number in php mysql

In the test.php file, create a sql statement to query the user data table, and use the mysqli_query function to execute the sql statement.

How to query the number in php mysql

In the test.php file, use the mysqli_num_rows function to obtain the number of records in the previous result set, and use echo to output it.

How to query the number in php mysql

Open the test.php file in the browser to view the results.

How to query the number in php mysql

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to query the number in php mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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