prepare("select * from subjects where subjectname = '$tsubj' ") ; $gts->execute() ; $srow = $gts->fetch(pdo::FETCH_ASSOC) ; $sbno = $srow['subject_id'] ; if (array_key_exists('submit', $_POST)) { //varriables $cls = $_POST['classid'] ; $trm = $_POST['acterm'] ; $yr = $_POST['yr'] ; $_SESSION["clas"] = $cls ; $_SESSION["tm"] = $trm ; $_SESSION["yrs"] = $yr ; if(isset($tmail)) $sql = $DBcon->prepare("select * from marks where ((acad_session = '$yr' and term = '$trm') and (stclass = '$cls' and subject_id = '$sbno' ))") ; else $sql = $DBcon->prepare("select * from marks where (acad_session = '$yr' and term = '$trm') and stclass = '$cls'") ; $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"] ; if(isset($tmail)) $del = $DBcon->prepare("delete from marks where( (stclass = '$c' and term = '$t') and (acad_session = '$y' and subject_id = '$sbno'))") ; else $del = $DBcon->prepare("delete from marks where( (stclass = '$c' and term = '$t') and (acad_session = '$y'") ; 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.' ; } ?>