How to Delete Multiple Records in PHP MySQL | Learn MySQL

How to Delete Multiple Records

0 3286

To delete multiple records, first of all, make a connection for database. A simple way to delete multiple records, you can use checkbox.

For this, check the following Example:

$connect=mysql_connect("hostname","username","password") OR die ("connection failed");

<!DOCTYPE html>

<meta charset="utf-8">
<title> Delete Multiple Records </title>

// PHP MySql Delete Query Code

for($i=0; $i<count($_POST['id']); $i++)
$sql="DELETE FROM table_name WHERE id='$delete_id'";
echo "Values have been deleted.";
echo "Can't delete these values.";

<form action="" method="post" enctype="multipart/form-data">
<table border="1" cellpadding="3" cellspacing="3">
<th> Id </th>
<th> Name </th>
<th> Email </th>
$query=mysql_query("SELECT * FROM table_name");
<td> <input type="checkbox" name="id[]" value="<?php echo $fetch['id']; ?>" /> </td>
<td> <?php echo $fetch['name']; ?> </td>
<td> <?php echo $fetch['message']; ?> </td>
<?php  }  ?>
<td colspan="3" align="center">
<input type="submit" name="delete" value="Submit" />



Best WordPress Hosting


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price

Leave a Reply

    Waiting for your comments