Home > Article > Backend Development > How to connect php to mysql and query data
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".
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!