Home  >  Article  >  Backend Development  >  How to output sql query results in php

How to output sql query results in php

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-04-19 18:10:445186browse

Method: 1. Use the "mysql_connect()" and "mysql_select_db()" functions to establish a connection with the database; 2. Use the "mysql_query()" function to execute the query statement "select * from table name"; 3. Use the echo statement to output the query results.

How to output sql query results in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Use navicat to create a new database database1, and create a new database database1 in database1 Create a new table table2 in the database, add new data in table2, and create a new php file named mysql_query

How to output sql query results in php

How to output sql query results in php

How to output sql query results in php

php outputs sql query results

1. Use the mysql_connect function to establish a connection with the database on the page, and use the mysql_select_db function to select the database to be queried. .

How to output sql query results in php

How to output sql query results in php

2. Add a query statement "$sql=select * from table2" to query the table2 table.

How to output sql query results in php

#3. Add the query statement $sql to the query database function mysql_query, and assign the return value to the variable query. Finally, open the mysql_query.php file in the browser to view the results of querying the content in the database.

How to output sql query results in php

Recommended: "2021 PHP interview questions summary (collection) " "php video tutorial

The above is the detailed content of How to output sql query results 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