Delete Values From Database
Home Courses Community Support
Delete Values From Database

In previous heading you have learned to updated the table data stored in database. Now we will code to delete the table data.

We have a table which have below records:

ID Name Phone Email Message
1 Anuj 9898989898 This is updated Message.
2 Ankur 5656565656 This row will be deleted.

Now run below query to delete the second record, save in id 2-

$con = mysqli_connect("localhost","root","","myweb");
if ($con->connect_error) {
    die("Connection failed: " . $con->connect_error);
$sql = "DELETE from form_data WHERE id=2";
if ($con->query($sql) === TRUE) {
	echo "Row has been successfully deleted.";
} else {
    echo "Error updating record: " . $con->error;

This code will delete the second row from table.


← Preview

Update Record in the Database


Our mission is to provide highly effective and quality education via innovative solutions. Geeksdemy look forward to bridge the gap between in-demand technology and academics in order to deliver innovative, easy, interesting and affordable learning across the Globe.


  • Python
  • Game Development with Unity 3D
  • Arduino
  • PCB & Circuit Designing
  • Robotics and Embedded C
  • 8051/8052 Embedded Systems
  • QuadCopter & UAV
  • MATLAB with Robotics
  • Raspberry Pi
Learn On the Go!
Get the Android App
Get the iOS App