php删除功能可以通过“php mysql delete”语句来实现,其语法为“delete from table_name where some_column = some_value”。
推荐:《php视频教程》
php删除功能:
php mysql delete
delete 语句用于从数据库表中删除行。
删除数据库中的数据
delete from 语句用于从数据库表中删除记录。
语法
delete from table_namewhere some_column = some_value
注释:请注意 delete 语法中的 where 子句。where 子句规定了哪些记录需要删除。如果您想省去 where 子句,所有的记录都会被删除!
为了让 php 执行上面的语句,我们必须使用 mysqli_query() 函数。该函数用于向 mysql 连接发送查询或命令。
实例
请看下面的 "persons" 表:
下面的实例删除 "persons" 表中所有 lastname='griffin' 的记录:
<?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);?>在这次删除
后,persons 表如下所示:
以上就是php删除功能如何实现的详细内容。