Home > Article > Backend Development > How to determine how many data are in the table in php
php method to determine how many pieces of data there are in the table: 1. Create a new PHP file; 2. Pass "$conn = new mysqli('10.5.15.177', 'root', '', 'test' )..." The code can be used to determine the number of data items in the table.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How does php determine how many data are in the table?
1. First, open the php editor and create a new php file, for example: index.php.
2. In index.php, enter the code:
$conn = new mysqli('10.5.15.177', 'root', '', 'test'); $sql = "select * from stu"; $r = $conn->query($sql); print_r($r->num_rows);
3. The browser runs the index.php page, and the stu table is printed out. The number of records is 5.
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to determine how many data are in the table in php. For more information, please follow other related articles on the PHP Chinese website!