{"id":584,"date":"2015-05-15T06:27:17","date_gmt":"2015-05-15T06:27:17","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=584"},"modified":"2023-07-06T08:32:54","modified_gmt":"2023-07-06T08:32:54","slug":"delete-multiple-records-from-mysql-in-php","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/","title":{"rendered":"Delete Multiple Records from MySQL Database in PHP"},"content":{"rendered":"<p>It is very time-consuming to delete records one by one from a large amount of data in the list. We can make it easier by deleting multiple records at once. With the bulk delete feature, you can make the large data list user-friendly by allowing the user to delete multiple rows with a single click. <b>Delete multiple records<\/b> with a single click is strongly recommended for the data management section in the web application.<\/p>\n<p>You can use the checkbox to select each record and delete all the selected rows after the remove request submission. Also, jQuery can be used to select or unselect all checkboxes at once in the data list. In this tutorial, we will show you how to <b>delete multiple records from MySQL database in PHP<\/b> with checkbox.<\/p>\n<p>In the example code, we will implement the following operations to <b>delete multiple records using checkboxes in PHP<\/b>.<\/p>\n<ul>\n<li>Fetch all users data from the database and list them in an HTML table.<\/li>\n<li>Add a checkbox in each row to select multiple records in the user&#8217;s data list.<\/li>\n<li>Add a checkbox in the table header to check or uncheck all checkboxes on a single click.<\/li>\n<li>Add delete button to remove all selected users from the table of MySQL database.<\/li>\n<\/ul>\n<h2>Create Database Table<\/h2>\n<p>A table needs to be created in the database to store the user&#8217;s data. The following SQL creates a <code>users<\/code> table with some basic fields in the MySQL database.<\/p>\n<pre style=\"color: rgb(0, 0, 0);\"><span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CREATE<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">TABLE<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`users`<\/span> (\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> AUTO_INCREMENT,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`first_name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">100<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`last_name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">100<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`email`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">200<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`phone`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">15<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`created`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`modified`<\/span> datetime <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n  <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`status`<\/span> tinyint(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">1<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">1<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COMMENT<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'1=Active, 0=Deactive'<\/span>,\r\n  PRIMARY <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">KEY<\/span> (<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span>)\r\n) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">ENGINE<\/span>=<span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">InnoDB<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CHARSET<\/span>=utf8 <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span>=utf8_unicode_ci;<\/pre>\n<h2>Database Configuration (dbConfig.php)<\/h2>\n<p>The <code>dbConfig.php<\/code> file is used to connect and select the database. Specify the database hostname (<code>$dbHost<\/code>), username (<code>$dbUsername<\/code>), password (<code>$dbPassword<\/code>), and name (<code>$dbName<\/code>) as per your MySQL database credentials.<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php<br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Database&nbsp;configuration<br \/><\/span><span style=\"color: #0000BB\">$dbHost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"localhost\"<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">$dbUsername&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"root\"<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">$dbPassword&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"root\"<\/span><span style=\"color: #007700\">;<br \/><\/span><span style=\"color: #0000BB\">$dbName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">\"codexworld\"<\/span><span style=\"color: #007700\">;<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Create&nbsp;database&nbsp;connection<br \/><\/span><span style=\"color: #0000BB\">$db&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;new&nbsp;<\/span><span style=\"color: #0000BB\">mysqli<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$dbHost<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbUsername<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbPassword<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$dbName<\/span><span style=\"color: #007700\">);<br \/><br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;connection<br \/><\/span><span style=\"color: #007700\">if&nbsp;(<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">)&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;die(<\/span><span style=\"color: #DD0000\">\"Connection&nbsp;failed:&nbsp;\"&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">connect_error<\/span><span style=\"color: #007700\">);<br \/>}<br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<h2>Data List with Checkboxes<\/h2>\n<p>In this file, we will fetch all the records from the <code>users<\/code> table and list them with checkboxes in an HTML table.<\/p>\n<p><b>JavaScript Code:<\/b><br \/>\njQuery is used to integrate the delete confirmation dialog and select all checkboxes functionality. So, include the jQuery library first.<\/p>\n<pre><span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">script<\/span> <span>src<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.7.0\/jquery.min.js\"<\/span>&gt;<\/span><span><\/span><span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">script<\/span>&gt;<\/span><\/pre>\n<p>The <code>delete_confirm()<\/code> function checks whether the user selects at least one checkbox and display an alert if the user has not checked any checkbox using JavaScript. Also, displays a confirmation popup before submitting the delete request to the server-side script.<\/p>\n<pre><span><span style=\"color: rgb(184, 84, 212);\">function<\/span> <span style=\"color: rgb(102, 132, 225);\">delete_confirm<\/span>(<span style=\"color: rgb(182, 86, 17);\"><\/span>)<\/span>{\r\n    <span style=\"color: rgb(184, 84, 212);\">if<\/span>($(<span style=\"color: rgb(96, 172, 57);\">'.checkbox:checked'<\/span>).length &gt; <span style=\"color: rgb(182, 86, 17);\">0<\/span>){\r\n        <span style=\"color: rgb(184, 84, 212);\">var<\/span> result = confirm(<span style=\"color: rgb(96, 172, 57);\">\"Are you sure to delete selected users?\"<\/span>);\r\n        <span style=\"color: rgb(184, 84, 212);\">if<\/span>(result){\r\n            <span style=\"color: rgb(184, 84, 212);\">return<\/span> <span style=\"color: rgb(182, 86, 17);\">true<\/span>;\r\n        }<span style=\"color: rgb(184, 84, 212);\">else<\/span>{\r\n            <span style=\"color: rgb(184, 84, 212);\">return<\/span> <span style=\"color: rgb(182, 86, 17);\">false<\/span>;\r\n        }\r\n    }<span style=\"color: rgb(184, 84, 212);\">else<\/span>{\r\n        alert(<span style=\"color: rgb(96, 172, 57);\">'Select at least 1 record to delete.'<\/span>);\r\n        <span style=\"color: rgb(184, 84, 212);\">return<\/span> <span style=\"color: rgb(182, 86, 17);\">false<\/span>;\r\n    }\r\n}\r\n<\/pre>\n<p>The following jQuery code is used to implement the <a href=\"https:\/\/www.codexworld.com\/select-deselect-all-checkboxes-using-jquery\/\">Select \/ Deselect All CheckBoxes<\/a> functionality. It helps the user to check \/ uncheck all checkboxes in the table with a single click.<\/p>\n<pre>$(<span style=\"color: rgb(182, 86, 17);\">document<\/span>).ready(<span><span style=\"color: rgb(184, 84, 212);\">function<\/span>(<span style=\"color: rgb(182, 86, 17);\"><\/span>)<\/span>{\r\n    $(<span style=\"color: rgb(96, 172, 57);\">'#select_all'<\/span>).on(<span style=\"color: rgb(96, 172, 57);\">'click'<\/span>,<span><span style=\"color: rgb(184, 84, 212);\">function<\/span>(<span style=\"color: rgb(182, 86, 17);\"><\/span>)<\/span>{\r\n        <span style=\"color: rgb(184, 84, 212);\">if<\/span>(<span style=\"color: rgb(184, 84, 212);\">this<\/span>.checked){\r\n            $(<span style=\"color: rgb(96, 172, 57);\">'.checkbox'<\/span>).each(<span><span style=\"color: rgb(184, 84, 212);\">function<\/span>(<span style=\"color: rgb(182, 86, 17);\"><\/span>)<\/span>{\r\n                <span style=\"color: rgb(184, 84, 212);\">this<\/span>.checked = <span style=\"color: rgb(182, 86, 17);\">true<\/span>;\r\n            });\r\n        }<span style=\"color: rgb(184, 84, 212);\">else<\/span>{\r\n             $(<span style=\"color: rgb(96, 172, 57);\">'.checkbox'<\/span>).each(<span><span style=\"color: rgb(184, 84, 212);\">function<\/span>(<span style=\"color: rgb(182, 86, 17);\"><\/span>)<\/span>{\r\n                <span style=\"color: rgb(184, 84, 212);\">this<\/span>.checked = <span style=\"color: rgb(182, 86, 17);\">false<\/span>;\r\n            });\r\n        }\r\n    });\r\n\t\r\n    $(<span style=\"color: rgb(96, 172, 57);\">'.checkbox'<\/span>).on(<span style=\"color: rgb(96, 172, 57);\">'click'<\/span>,<span><span style=\"color: rgb(184, 84, 212);\">function<\/span>(<span style=\"color: rgb(182, 86, 17);\"><\/span>)<\/span>{\r\n        <span style=\"color: rgb(184, 84, 212);\">if<\/span>($(<span style=\"color: rgb(96, 172, 57);\">'.checkbox:checked'<\/span>).length == $(<span style=\"color: rgb(96, 172, 57);\">'.checkbox'<\/span>).length){\r\n            $(<span style=\"color: rgb(96, 172, 57);\">'#select_all'<\/span>).prop(<span style=\"color: rgb(96, 172, 57);\">'checked'<\/span>,<span style=\"color: rgb(182, 86, 17);\">true<\/span>);\r\n        }<span style=\"color: rgb(184, 84, 212);\">else<\/span>{\r\n            $(<span style=\"color: rgb(96, 172, 57);\">'#select_all'<\/span>).prop(<span style=\"color: rgb(96, 172, 57);\">'checked'<\/span>,<span style=\"color: rgb(182, 86, 17);\">false<\/span>);\r\n        }\r\n    });\r\n});<\/pre>\n<p><b>HTML &#038; PHP Code:<\/b><br \/>\nThe user can check single or multiple records using checkbox in the table and delete multiple records from the MySQL database.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Include the <code>dbConfig.php<\/code> file to connect the MySQL database.<\/li>\n<li>All the records are retrieved from the users table.<\/li>\n<li>Multiple records can be selected using checkbox provided on each table row.<\/li>\n<li>By clicking the checkbox in the table header, all checkboxes will be checked or unchecked.<\/li>\n<li>Once the delete button is clicked, a confirmation dialog will appear.<\/li>\n<li>After the confirmation, the form is submitted to delete selected rows from the database.<\/li>\n<\/ul>\n<pre><span style=\"color: rgb(108, 107, 90);\">&lt;!-- Display the status message --&gt;<\/span>\r\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">if(!empty(<\/span><span style=\"color: #0000BB\">$statusMsg<\/span><span style=\"color: #007700\">)){&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n<span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">div<\/span> <span>class<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"alert alert-success\"<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n\r\n<span style=\"color: rgb(108, 107, 90);\">&lt;!-- Users data list --&gt;<\/span>\r\n<span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">form<\/span> <span>name<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"bulk_action_form\"<\/span> <span>action<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"delete_submit.php\"<\/span> <span>method<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"post\"<\/span> <span>onSubmit<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"return delete_confirm();\"<\/span>\/&gt;<\/span>\r\n    <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">table<\/span> <span>class<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"bordered\"<\/span>&gt;<\/span>\r\n        <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">thead<\/span>&gt;<\/span>\r\n        <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">tr<\/span>&gt;<\/span>\r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">th<\/span>&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">input<\/span> <span>type<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"checkbox\"<\/span> <span>id<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"select_all\"<\/span> <span>value<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"\"<\/span>\/&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">th<\/span>&gt;<\/span>        \r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">th<\/span>&gt;<\/span>First Name<span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">th<\/span>&gt;<\/span>\r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">th<\/span>&gt;<\/span>Last Name<span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">th<\/span>&gt;<\/span>\r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">th<\/span>&gt;<\/span>Email<span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">th<\/span>&gt;<\/span>\r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">th<\/span>&gt;<\/span>Phone<span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">th<\/span>&gt;<\/span>\r\n        <span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">tr<\/span>&gt;<\/span>\r\n        <span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">thead<\/span>&gt;<\/span>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #0000BB\">&lt;?php<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;the&nbsp;database&nbsp;configuration&nbsp;file<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">include_once&nbsp;<\/span><span style=\"color: #DD0000\">'dbConfig.php'<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;users&nbsp;from&nbsp;the&nbsp;database<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$query&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"SELECT&nbsp;*&nbsp;FROM&nbsp;users&nbsp;ORDER&nbsp;BY&nbsp;id&nbsp;DESC\"<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;List&nbsp;all&nbsp;records<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">if(<\/span><span style=\"color: #0000BB\">$query<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">num_rows&nbsp;<\/span><span style=\"color: #007700\">&gt;&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while(<\/span><span style=\"color: #0000BB\">$row&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$query<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fetch_assoc<\/span><span style=\"color: #007700\">()){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n        <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">tr<\/span>&gt;<\/span>\r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">input<\/span> <span>type<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"checkbox\"<\/span> <span>name<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"checked_id[]\"<\/span> <span>class<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"checkbox\"<\/span> <span>value<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\"<\/span>\/&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span>        \r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'first_name'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span>\r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'last_name'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span>\r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'email'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span>\r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'phone'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span>\r\n        <span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">tr<\/span>&gt;<\/span>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}&nbsp;}else{&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n            <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">tr<\/span>&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">td<\/span> <span>colspan<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"5\"<\/span>&gt;<\/span>No records found.<span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">td<\/span>&gt;<\/span><span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">tr<\/span>&gt;<\/span>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n    <span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">table<\/span>&gt;<\/span>\r\n    <span style=\"color: rgb(186, 98, 54);\">&lt;<span style=\"color: rgb(186, 98, 54);\">input<\/span> <span>type<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"submit\"<\/span> <span>class<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"btn btn-danger\"<\/span> <span>name<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"bulk_delete_submit\"<\/span> <span>value<\/span>=<span style=\"color: rgb(125, 151, 38);\">\"Delete\"<\/span>\/&gt;<\/span>\r\n<span style=\"color: rgb(186, 98, 54);\">&lt;\/<span style=\"color: rgb(186, 98, 54);\">form<\/span>&gt;<\/span>\r\n<\/pre>\n<p>After the confirmation, the form is submitted to the server-side script (<code>delete_submit.php<\/code>) for proceeding with the delete request.<\/p>\n<h2>Delete All Records from Database with PHP<\/h2>\n<p>The <code>delete_submit.php<\/code> file handles the multiple records delete operations with PHP and MySQL.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Check whether the delete request is submitted.<\/li>\n<li>Check whether the user selects at least one record and the ID array is not empty.<\/li>\n<li>Get selected IDs using <b>PHP $_POST<\/b> method and convert this array to a string using <b>implode() function in PHP<\/b>.<\/li>\n<li>Delete records from the database based on the selected user&#8217;s ID using PHP and MySQL.<\/li>\n<li>Display the status message on the web page.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Include&nbsp;the&nbsp;database&nbsp;configuration&nbsp;file <br \/><\/span><span style=\"color: #007700\">include_once&nbsp;<\/span><span style=\"color: #DD0000\">'dbConfig.php'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;If&nbsp;record&nbsp;delete&nbsp;request&nbsp;is&nbsp;submitted <br \/><\/span><span style=\"color: #007700\">if(isset(<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'bulk_delete_submit'<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;If&nbsp;id&nbsp;array&nbsp;is&nbsp;not&nbsp;empty <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">if(!empty(<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'checked_id'<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;all&nbsp;selected&nbsp;IDs&nbsp;and&nbsp;convert&nbsp;it&nbsp;to&nbsp;a&nbsp;string <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$idStr&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">implode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">','<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$_POST<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'checked_id'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Delete&nbsp;records&nbsp;from&nbsp;the&nbsp;database <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$delete&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">query<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"DELETE&nbsp;FROM&nbsp;users&nbsp;WHERE&nbsp;id&nbsp;IN&nbsp;(<\/span><span style=\"color: #0000BB\">$idStr<\/span><span style=\"color: #DD0000\">)\"<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;If&nbsp;delete&nbsp;is&nbsp;successful <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">if(<\/span><span style=\"color: #0000BB\">$delete<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Selected&nbsp;users&nbsp;have&nbsp;been&nbsp;deleted&nbsp;successfully.'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Some&nbsp;problem&nbsp;occurred,&nbsp;please&nbsp;try&nbsp;again.'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}else{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$statusMsg&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'Select&nbsp;at&nbsp;least&nbsp;1&nbsp;record&nbsp;to&nbsp;delete.'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>} <br \/> <br \/><\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/php-crud-operations-with-mysqli-extension\/\">PHP CRUD Operations with MySQLi Extension<\/a><\/span><\/p>\n<h2>Conclusion<\/h2>\n<p>The multiple records removal functionality is very useful for the data list. You can use bulk delete functionality in the data management section of your web application. It will make your web application user-friendly because the user doesn&#8217;t need to click multiple times to delete multiple records from the database. Using our example code you can check\/uncheck all records at once and delete all records from the database on a single click using PHP.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is very time-consuming to delete records one by one from a large amount of data in the list. We can make it easier by deleting multiple records at once. With the bulk delete feature, <\/p>\n","protected":false},"author":1,"featured_media":5386,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[121,98,16,19,14],"class_list":["post-584","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-checkboxes","tag-database","tag-jquery","tag-mysql","tag-php","cat-4-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Delete Multiple Records from MySQL Database in PHP - CodexWorld<\/title>\n<meta name=\"description\" content=\"Delete multiple records from database in PHP - Allow the user to select \/ deselect all checkboxes using jQuery and delete multiple records from MySQL database using PHP. The example code to delete multiple rows with checkbox on a single click in PHP.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Delete Multiple Records from MySQL Database in PHP - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Delete multiple records from database in PHP - Allow the user to select \/ deselect all checkboxes using jQuery and delete multiple records from MySQL database using PHP. The example code to delete multiple rows with checkbox on a single click in PHP.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2015-05-15T06:27:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-06T08:32:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/05\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Delete Multiple Records from MySQL Database in PHP\",\"datePublished\":\"2015-05-15T06:27:17+00:00\",\"dateModified\":\"2023-07-06T08:32:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/\"},\"wordCount\":671,\"commentCount\":11,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png\",\"keywords\":[\"Checkboxes\",\"Database\",\"jQuery\",\"MySQL\",\"PHP\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/\",\"name\":\"Delete Multiple Records from MySQL Database in PHP - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png\",\"datePublished\":\"2015-05-15T06:27:17+00:00\",\"dateModified\":\"2023-07-06T08:32:54+00:00\",\"description\":\"Delete multiple records from database in PHP - Allow the user to select \\\/ deselect all checkboxes using jQuery and delete multiple records from MySQL database using PHP. The example code to delete multiple rows with checkbox on a single click in PHP.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/05\\\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png\",\"width\":1920,\"height\":1080,\"caption\":\"delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/delete-multiple-records-from-mysql-in-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Delete Multiple Records from MySQL Database in PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Delete Multiple Records from MySQL Database in PHP - CodexWorld","description":"Delete multiple records from database in PHP - Allow the user to select \/ deselect all checkboxes using jQuery and delete multiple records from MySQL database using PHP. The example code to delete multiple rows with checkbox on a single click in PHP.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/","og_locale":"en_US","og_type":"article","og_title":"Delete Multiple Records from MySQL Database in PHP - CodexWorld","og_description":"Delete multiple records from database in PHP - Allow the user to select \/ deselect all checkboxes using jQuery and delete multiple records from MySQL database using PHP. The example code to delete multiple rows with checkbox on a single click in PHP.","og_url":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2015-05-15T06:27:17+00:00","article_modified_time":"2023-07-06T08:32:54+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/05\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Delete Multiple Records from MySQL Database in PHP","datePublished":"2015-05-15T06:27:17+00:00","dateModified":"2023-07-06T08:32:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/"},"wordCount":671,"commentCount":11,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/05\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png","keywords":["Checkboxes","Database","jQuery","MySQL","PHP"],"articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/","url":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/","name":"Delete Multiple Records from MySQL Database in PHP - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/05\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png","datePublished":"2015-05-15T06:27:17+00:00","dateModified":"2023-07-06T08:32:54+00:00","description":"Delete multiple records from database in PHP - Allow the user to select \/ deselect all checkboxes using jQuery and delete multiple records from MySQL database using PHP. The example code to delete multiple rows with checkbox on a single click in PHP.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/05\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/05\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png","width":1920,"height":1080,"caption":"delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/delete-multiple-records-from-mysql-in-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Delete Multiple Records from MySQL Database in PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/05\/delete-multiple-records-from-mysql-database-using-php-bulk-delete-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-9q","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=584"}],"version-history":[{"count":14,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/584\/revisions"}],"predecessor-version":[{"id":5385,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/584\/revisions\/5385"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/5386"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}