Home >Backend Development >PHP Problem >How to delete data in data table in php

How to delete data in data table in php

王林
王林Original
2020-07-29 14:42:504609browse

How to delete data in the data table in php: You can delete it through the mysqli_query() function combined with the DELETE FROM statement. The DELETE FROM statement is used to delete records from a database table. The syntax structure is: [DELETE FROM table WHERE condition].

How to delete data in data table in php

#DELETE FROM statement is used to delete records from a database table.

(Recommended tutorial: php graphic tutorial)

Syntax:

DELETE FROM table_name
WHERE some_column = some_value

Persons table:

How to delete data in data table in php

(Learning video recommendation: php video tutorial)

Code implementation:

<?php
$con=mysqli_connect("localhost","username","password","database");// 检测连接
if (mysqli_connect_errno()){   
    echo "连接失败: " . mysqli_connect_error();
}
mysqli_query($con,"DELETE FROM Persons WHERE LastName=&#39;Griffin&#39;");
mysqli_close($con);
?>

Deleted table:

How to delete data in data table in php

The above is the detailed content of How to delete data in data table 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