How to query 10 pieces of data at a time by php
This article mainly shows you "php how to query 10 pieces of data at a time", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "php how to query 10 pieces of data at a time" this article.
Php query 10 pieces of data at a 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, query only the first 10 items through limit restrictions; 4, loop output data through the while statement.
This article operating environment: Windows7 system, PHP7.1, Dell G3 computer.
The php+mysql implementation queries only the first 10 pieces of data:
In the mysql database, create a user table and insert multiple pieces of data into the table for testing.
Create a test.php file within which you use the header () method to set the encoding format of the page to utf-8.
Within the test.php file, connect to the mysql database and use mysqli_select_db to select the database you want to operate on.
Within the test.php file, create a sql statement using select, query only the first 10 items through the limit restriction, and then use the mysqli_query function to execute the sql statement.
Within the test.php file, use the mysqli_fetch_assoc function to convert the result set data into an array and loop out the data through the while statement.
Open the test.php file in a browser and view the results.
The above is all the contents of the article "how to query 10 pieces of data at a time by php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!