SQL: Delete
SQL DELETE Essentials
Always Include WHERE
DELETE FROM users WHERE id = 231 — without WHERE, you delete every row.
Pass IDs via URL Variable
<a href='deleteConfirm.php?id=231'>Delete</a> — read with $_GET['id'].
Sanitize the ID
Cast to int: $id = (int) $_GET['id']; — prevents SQL injection in DELETE statements.
Confirm Before Deleting
Always show a confirmation page before executing DELETE — destructive actions deserve a second click.
Noble Desktop's Full-Stack Web Development Certificate teaches modern back-end development — concepts that carry across PHP, Node.js, and Python.
Learn how to delete records from a database in this comprehensive PHP and MySQL tutorial that covers the DELETE statement, deleting rows from a database, and passing ID variables in a URL.