prepare("SELECT subject_id FROM subjects where subjectname = '$sbjn'"); $getsid->execute() ; $grw = $getsid->fetch(pdo::FETCH_ASSOC) ; $sid = $grw['subject_id'] ; $_SESSION["sid"] = $sid ; $sql = $DBcon->prepare("select * from marks where ((acad_session = '$yr' and term = '$trm') and (stclass = '$cls' and subject_id = $sid)) ") ; $sql->execute() ; $num_rows =$sql->rowcount() ; } if (array_key_exists('deletebt', $_POST)) { if(isset($_SESSION["clas"] )) { $c = $_SESSION["clas"] ; $t = $_SESSION["tm"] ; $y = $_SESSION["yrs"] ; $s = $_SESSION["sid"] ; $del = $DBcon->prepare("delete from marks where ( (stclass = '$c' and term = '$t') and (acad_session = '$y' and subject_id = $s)) ") ; if($del->execute()) $msg = 'Records Deleted Succesfully' ; else $msg = 'Some thing went wrong, Records was not deleted' ; // $_SESSION = array(); //session_destroy(); } else $ms = 'Please Select Result Data and Display the Result first then Click Delete Button after that.' ; } ?>