How to query mysql database data in php: First use navicat to create a new database and create a table; then add data and connect to the database; then use the [mysql_select_db] function to select the database to be queried; finally, put the file in the browser Just open it in .

How to query mysql database data in php:
1. Use navicat to create a new database database1

2. Create a new table table2 in the database1 database

##3. Add new data in table2

4. Create a new database named mysql_query

5. Use the mysql_connect function to establish a connection with the database on the page

6. Use the mysql_select_db function to select the database to be queried

7. Add a query statement for querying the table2 table "
$sql=select * from table2“

8. Add the query statement $sql to the query database function mysql_query, and assign the return value to the variable query

9. Define an array arr, use the mysql_fetch_assco function to obtain the query results, use while traversal to store the query results into the array arr
, and finally print arr.

10. Open the mysql_query.php file in the browser and view the results of querying the content in the database

Related learning recommendations: PHP programming from entry to proficiency
The above is the detailed content of How to query mysql database data 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