Home  >  Article  >  Backend Development  >  How to connect php to mysql and query data

How to connect php to mysql and query data

藏色散人
藏色散人Original
2020-10-13 09:25:153790browse

How to connect php to mysql and query data: first create a PHP sample file; then connect to the database through the username and password; and finally query through the query statement "select* from goods".

How to connect php to mysql and query data

Recommended: "PHP Video Tutorial"

php connection and query mysql database

 query($sql);
print_r($results);
//遍历循环打印数据
while ($row = mysqli_fetch_array($results))
{
//    print_r($row);
    echo $row['goods_name'];
    echo "
"; } //释放 mysqli_free_result($results); //关闭连接 mysqli_close($mysql); ?>

The above is the detailed content of How to connect php to mysql and query data. 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