How to Delete Multiple Records From MySQL Using PHP

So here i will tell you how to delete bulk records from MySQL table in PHP with checkbox, you just need to select checkbox which one you want to delete and hit submit button to delete. As we know, Its very time consuming to delete records one by one. Everyone wants to delete bulk record on single event only. You may also like How to Add, Edit and Delete Records Using jQuery, Ajax, PHP and MySQL.

PHP and HTML Code

    define('DB_SERVER', "localhost");
    define('DB_USER', "root");
    define('DB_PASS', "");
    define('DB_DATABASE', "ieltsmedidb");
    $con = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);

if(isset($_POST['delete_records']) && count($_POST['no'])>0)
        mysqli_query($con,"delete from medical_student where student_id = '$row_no' ");

        $select = mysqli_query($con, "SELECT * FROM medical_student");
        <form method="post" action="">
            <table align="center" cellpadding="10" border="1">
                while ($row = mysqli_fetch_assoc($select)) {
                    echo "<tr>";
                    echo "<td><input type='checkbox' name='no[]' value='" . $row['student_id'] . "'></td><td>" . $row['student_name'] . "</td><td>" . $row['email'] . "</td>";
                    echo "</tr>";
            <input type="submit" name="delete_records" value="Delete Records">

Leave a Reply

Your email address will not be published. Required fields are marked *