吴裕雄--天生自然 PHP开发学习:MySQL子句
Posted tszr
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了吴裕雄--天生自然 PHP开发学习:MySQL子句相关的知识,希望对你有一定的参考价值。
<?php $con=mysqli_connect("localhost","username","password","database"); // 检测连接 if (mysqli_connect_errno()) { echo "连接失败: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM Persons ORDER BY age"); while($row = mysqli_fetch_array($result)) { echo $row[‘FirstName‘]; echo " " . $row[‘LastName‘]; echo " " . $row[‘Age‘]; echo "<br>"; } mysqli_close($con); ?>
<?php $con=mysqli_connect("localhost","username","password","database"); // 检测连接 if (mysqli_connect_errno()) { echo "连接失败: " . mysqli_connect_error(); } $result = mysqli_query($con,"SELECT * FROM Persons WHERE FirstName=‘Peter‘"); while($row = mysqli_fetch_array($result)) { echo $row[‘FirstName‘] . " " . $row[‘LastName‘]; echo "<br>"; } ?>
<?php $con=mysqli_connect("localhost","username","password","database"); // 检测连接 if (mysqli_connect_errno()) { echo "连接失败: " . mysqli_connect_error(); } mysqli_query($con,"UPDATE Persons SET Age=36 WHERE FirstName=‘Peter‘ AND LastName=‘Griffin‘"); mysqli_close($con); ?>
<?php $con=mysqli_connect("localhost","username","password","database"); // 检测连接 if (mysqli_connect_errno()) { echo "连接失败: " . mysqli_connect_error(); } mysqli_query($con,"DELETE FROM Persons WHERE LastName=‘Griffin‘"); mysqli_close($con); ?>
以上是关于吴裕雄--天生自然 PHP开发学习:MySQL子句的主要内容,如果未能解决你的问题,请参考以下文章