Home> Topics> php mysql> body text

How to query the number of mysql records in php

藏色散人
Release: 2020-10-19 11:50:00
Original
2886 people have browsed it

How to query the number of mysql records in php: 1. Use the "mysql_num_rows" function to query the number of mysql records; 2. Query the number of mysql records by modifying the query statement and using "COUNT(*)" as the query content.

How to query the number of mysql records in php

Recommended: "PHP video tutorial" "php mysql"

PHP query statement ,Return the total number of records

PHP query statement, there are two methods to obtain the total number of records queried.

MySQLi process-oriented approach

$sql = "SELECT id, firstname, lastname FROM MyGuests"; $result = mysqli_query($conn, $sql); num_rows=mysqli_num_rows($result);
Copy after login

First, use the mysql_num_rows function, example code:

Copy after login

The second is to modify the query statement, using COUNT(*) as the query content, example Code:

Copy after login

The above is the detailed content of How to query the number of mysql records in php. 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
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!