PHP Basic Tutorial
MySQL Connection
Deleting data in a MySQL table using PHP involves executing an SQL DELETE query. You can either use the procedural or object-oriented approach for interacting with the database.
DELETE FROM table_name WHERE condition;
The following example updates the name
and age
of the user with id=1
.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Note
Without a WHERE
clause, all records in the table would be deleted. Make sure to specify which row(s) you want to delete.