Home  >  Article  >  Backend Development  >  How to query mysql database data in php?

How to query mysql database data in php?

coldplay.xixi
coldplay.xixiOriginal
2020-07-18 13:56:117278browse

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?

How to query mysql database data in php:

1. Use navicat to create a new database database1

How to query mysql database data in php?

2. Create a new table table2 in the database1 database

How to query mysql database data in php?

##3. Add new data in table2

How to query mysql database data in php?

4. Create a new database named mysql_query

How to query mysql database data in php?

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

How to query mysql database data in php?

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

How to query mysql database data in php?

7. Add a query statement for querying the table2 table "

$sql=select * from table2“

How to query mysql database data in php?

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

How to query mysql database data in php?

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.

How to query mysql database data in php?

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

How to query mysql database data in php?

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