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 email@emailserver.com This is updated Message.
2 Ankur 5656565656 myemail@mydomain.com This row will be deleted.


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

<?php
$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;
}
$con->close();
?>


This code will delete the second row from table.
 

 

← Preview

Update Record in the Database

NOTES

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.

Courses

  • 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