<?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 semisterperiod SET deleted_by='$stafNo' WHERE periodID='$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 semisterperiod WHERE periodID='$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:period.php');
                echo "<script type='text/javascript'> document.location = 'period.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 Semester Period Deleted!</span>
                    </div>';
            }
        }
    }  
?>                                                             