Home  >  Article  >  Backend Development  >  How to query 10 pieces of data each time in php

How to query 10 pieces of data each time in php

藏色散人
藏色散人Original
2021-11-23 09:34:412708browse

How to query 10 pieces of data in php each time: 1. Create a user table in the mysql database; 2. Connect to the mysql database and use mysqli_select_db to select the database; 3. Only query the first 10 pieces through limit; 4. Use the while statement to loop through the data output.

How to query 10 pieces of data each time in php

#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.

How does php query 10 pieces of data each time?

php mysql implementation only queries the first 10 pieces of data:

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

How to query 10 pieces of data each time in php

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 10 pieces of data each time in php

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

How to query 10 pieces of data each time in php

In the test.php file, use select to create a sql statement, and limit the query to only the first 10 items through limit, and then use the mysqli_query function to execute the sql statement.

How to query 10 pieces of data each time in php

In the test.php file, use the mysqli_fetch_assoc function to convert the result set data into an array form, and output the data through a while statement loop.

How to query 10 pieces of data each time in php

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

How to query 10 pieces of data each time in php

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to query 10 pieces of data each time 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