Delete Record From MySQL Table using PHPMyAdmin

Step 1: Select the name of the table from database and click on Browse  link it will display all the records from the table as shown below:

Delete Record

Step 2: Select the record from the list and click on button as shown below:

Delete Record

Step 3: As you click on button it will display confirmation message as shown below:

Delete Record

Step 4: Click on OK button to delete record.


Delete Record from MySQL table using PHP Script

In order to delete record from database table write following PHP script in DeleteRecord.php file as shown below:

<Title> Delete Record</title>
<table border="1" >
<th>Customer Code</th>
<th>Customer Name</th>
<th>Customer City</th>
// Establish Connection with Database
$con = mysql_connect ("localhost","root");
// Select Database
mysql_select_db ("DBDEMO", $con);
// specify the query to execute
$sql = "select * from Customer_Master";
// execute query
$result = mysql_query ($sql,$con);
// Loop through each records
While ($row = mysql_fetch_array ($result))
$Code=$row ['CustomerCode'];
$Name=$row ['CustomerName'];
$City=$row ['City'];
<td><?php echo $Code;?></td>
<td><?php echo $Name;?></td>
<td><?php echo $City;?></td>
<td><a href="RemoveRecord.php?CustomerCode=<?php echo $Code;      ?>">Delete</a></td>
// Close the connection
mysql_close ($con);

The above script display records from database table and provides a link of delete option as shown below:

Delete Record

As you click on delete hyperlink it will redirect you to RemoveRecord.php file with CustomerCode passed as a query string in the URL. Create RemoveRecord.php file as shown below:

$Code = $_GET['CustomerCode'];
// Establish Connection with MYSQL
$con = mysql_connect("localhost","root");
// Select Database
mysql_select_db("DBDEMO", $con);
// Specify the query to Insert Record
$sql = "delete from Customer_Master where       CustomerCode=".$Code."";
// Execute query
// Close The Connection
echo "Record Deleted Successfully";

The above script retrieves CustomerCode from the query string and deletes that customer from table.

Download Projects

Download Programs