Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Multuple deletion in Mysql using PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 87
    Comment on it

    Hello Reader's If you want to handle your html form to delete multiple value at once then by using Check box in array you can do it.
    lets see one example as below:-

    <?php $sql = "SELECT * FROM guest_book";
                                $res = mysql_query($sql);
                                if (mysql_num_rows($res)) {
                                $query = mysql_query("SELECT * FROM guest_book ORDER BY id");
                                $i=1;
                                while($row = mysql_fetch_assoc($query)){
                                ?>
    
    
    <input type="checkbox" name="checkboxstatus[<?php echo $i; ?>]" value="<?php echo $row['id']; ?>"  />
    
    <?php $i++; }} ?>
    
    
    <input type="submit" value="Delete" name="Delete" />
    
    if($_REQUEST['Delete'] != '')
    {
        if(!empty($_REQUEST['checkboxstatus'])) {
            $checked_values = $_REQUEST['checkboxstatus'];
            foreach($checked_values as $val) {
                $sqldel = "DELETE from guest_book WHERE id = '$val'";
               mysql_query($sqldel);
    
            }
        }
    } 
    

    In the page above you will see multiple select box and on selecting them you can delete multiple values at once

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: