PHP MySql Delete

PHP MySql DELETE clause tutorial will explain you How to delete data in MySQL database with PHP? with  example. PHP MySql DELETE clause is the command used to delete row/rows from table.

Delete data in a database using PHP MySql DELETE clause

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

Syntax for the PHP MySQL delete Query:

e.g. the following SQL statement, if put into a query, would delete record whose firstname is Fred:
DELETE FROM $tablename WHERE firstname = “Fred”

Example on MySQL Delete :

Example in which we delete record from table where ID = 1.
Table containing the following fields:

  • ID – auto generated integer
  • FName – First Name, varchar
  • LName – Last Name, varchar
  • PHONE – Phone number, varchar

Consider this is a table before deletion:

ID First Name Last Name Phone Number
0 Kim Kad 8912543287
1 Jon Job 9634234976

PHP code to update record from above table:

Output :

ID First Name Last Name Phone Number
0 Kim Kad 8912543287
Previous articlePHP MySQL UPDATE Query
Next articlePHP Database ODBC
I am a young Information Systems Security Engineer(CEH). I had started with penetration testing when i am 17 years old. It all started with Kali linux and Metasploit.In free time i will play with Security holes/Bug bounty/Pentesting and Hacking !!!