Home > Article > Backend Development > How to query the number in php mysql
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.
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.
Create a test.php file, and within the file, use the header() method to set the encoding format of the page to utf-8.
In the test.php file, connect to the mysql database and use mysqli_select_db to select the database to operate.
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.
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.
Open the test.php file in the browser to view the results.
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!