<?php                                                                        
    // Check if delete button active, start this
    if(isset($_POST['delete'])){
        
        $del_id = mysql_real_escape_string($_POST['delete']);

        if(!$uppdate=mysql_query("update miscellaneous SET deleted_by='$stafNo' WHERE miscellaneousID='$del_id'"))
        {
            echo'<div class="alert alert-danger absolue center text-center" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                    <span class="text-danger"><b>Failed to delete:</b> Error occured while trying to read staff info on delete: <br>'.mysql_error().'</span>
                </div>';
        }else
        {
            //delete row(s) of record(s)
            $sql = "DELETE FROM miscellaneous WHERE miscellaneousID='$del_id'";
            $deleted = mysql_query($sql);
            //get no. of rows deleted
            $records=  mysql_affected_rows();

            // if successful redirect to refresh page
            if($records>0){            
                $_SESSION["del"]='True';
                header('Location:miscellaneous.php');
                echo "<script type='text/javascript'> document.location = 'miscellaneous.php'; </script>";
                exit();
            }else{
                echo'<div class="alert alert-warning absolue center text-center" role="alert">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">×</span>
                        </button>
                        <span class="text-warning">No Miscellaneous deleted!</span>
                    </div>';
            }
        }
    }  
?>                                                             