Home  >  Article  >  Backend Development  >  How to determine how many data are in the table in php

How to determine how many data are in the table in php

藏色散人
藏色散人Original
2021-11-03 10:19:351968browse

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.

How to determine how many data are in the table in php

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.

How to determine how many data are in the table in 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.

How to determine how many data are in the table in php

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!

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