prepare("select * from average where grades = :a ") ; $alpha->bindparam(':a', $af) ; $alpha->execute() ; if($alpha->rowcount() > 0) { $rowds = $alpha->FETCH(PDO::FETCH_ASSOC) ; $as = $rowds['start'] ; $ae = $rowds['end'] ; } //GET GOOD GRADEFail $gd = 'GOOD' ; $good =$DBcon->prepare("select * from average where grades =:f ") ; $good->bindparam(':f' , $gd) ; $good->execute() ; if($good->rowcount() > 0) { $rowfl = $good->FETCH(PDO::FETCH_ASSOC) ; $gs = $rowfl['start'] ; $ge = $rowfl['end'] ; } //get credits grade $cd = 'Credit' ; $crd = $DBcon->prepare( "select * from average where grades = :c ") ; $crd->bindparam(':c', $cd) ; $crd->execute() ; if($crd->rowcount() > 0) { $rowcr = $crd->FETCH(PDO::FETCH_ASSOC) ; $cs = $rowcr['start'] ; $ce = $rowcr['end'] ; } //get pass grade $p = 'Pass' ; $pass = $DBcon->prepare("select * from average where grades = :p ") ; $pass->bindparam(':p' , $p) ; $pass->execute() ; if($pass->rowcount() > 0) { $rowps = $pass->FETCH(PDO::FETCH_ASSOC) ; $ps = $rowps['start'] ; $pe = $rowps['end'] ; } //get failure grades $f = 'Fail' ; $fail =$DBcon->prepare("select * from average where grades =:f ") ; $fail->bindparam(':f' , $f) ; $fail->execute() ; if($fail->rowcount() > 0) { $rowfl = $fail->FETCH(PDO::FETCH_ASSOC) ; $fs = $rowfl['start'] ; $fe = $rowfl['end'] ; } //get promotional average $pa = 'Promotion Average' ; $pro = $DBcon->prepare("select * from average where grades = :pr "); $pro->bindparam(':pr' , $pa) ; $pro->execute() ; if($pro->rowcount() > 0) { $rowpro = $pro->FETCH(PDO::FETCH_ASSOC) ; $prs = $rowpro['start'] ; $pre = $rowpro['end'] ; } //end.... $sqlname = $DBcon->prepare("select * from students where regno = :reg " ) ; $sqlname->bindparam(':reg' , $regno) ; $sqlname->execute() ; if ($sqlname->rowcount() > 0) { $rowa = $sqlname->FETCH(PDO::FETCH_ASSOC) ; $studname = $rowa['studentname'] ; $md = $rowa['middlename'] ; $ln = $rowa['lastname'] ; $avat = $rowa['avatar'] ; $names = $studname.' '.$md.' '.$ln ; $avat = $rowa['avatar'] ; } //GET NUMBER IN CLASS IN THIRD TERM $sqlpoc = $DBcon->prepare(" select distinct stregno from marks where (term =:tm and acad_session = :yr ) and stclass= :kls " ); $sqlpoc->bindparam(':tm' , $term) ; $sqlpoc->bindparam(':yr' , $schyear) ; $sqlpoc->bindparam(':kls' , $classid) ; $sqlpoc->execute() ; $numbt = $sqlpoc->rowcount() ; $_SESSION["classnumt"] = $numbt ; //END //GET NUMBER IN CLASS IN SESSION $sqlpocy = $DBcon->prepare(" select distinct stregno from marks where (stclass= :kls and acad_session = :yr )"); //$sqlpoc->bindparam(':tm' , $term) ; $sqlpocy->bindparam(':yr' , $schyear) ; $sqlpocy->bindparam(':kls' , $classid) ; $sqlpocy->execute() ; $numbty = $sqlpocy->rowcount() ; $_SESSION["classnumty"] = $numbty ; //END /* //get minimum no of subject $sqlm = $DBcon->prepare("select * from subjno where (classlevel = :kls and term = :tm) and yr = :y ") ; //$sqlm->bindparam(':kls' , $classid) ; $sqlm->bindparam(':kls' , $stclass) ; $sqlm->bindparam(':tm' , $term) ; $sqlm->bindparam(':y',$schyear) ; $sqlm->execute() ; $rowm = $sqlm->FETCH(PDO::FETCH_ASSOC) ; $min = $rowm['nos'] ; */ // //get minimum no of subject $sqlm = $DBcon->prepare("select * from subjno where classlevel = :kls ") ; $sqlm->bindparam(':kls' , $classid) ; $sqlm->execute() ; $rowm = $sqlm->FETCH(PDO::FETCH_ASSOC) ; $min = $rowm['nos'] ; //get next term fees and resumption $sqlt = $DBcon->prepare("select * from next" ) ; //$sqlname->bindparam(':reg' , $regno) ; $sqlt->execute() ; if ($sqlt->rowcount() > 0) { $rowat = $sqlt->FETCH(PDO::FETCH_ASSOC) ; $nxtf = $rowat['fees'] ; $nxtr = $rowat['resume'] ; } ?>

Term THIRD TERM & CUMULATIVE REPORT Class width="120" height= "100" alt="Student Image"/>
Name of Student House  
Admission No Session
prepare("select distinct subject_id from marks where (acad_session = :yr and stclass = :kls)" ); $skl->bindparam(':yr' , $schyear) ; $skl->bindparam(':kls' , $classid) ; $skl->execute() ; while($rowsubj = $skl->FETCH(PDO::FETCH_ASSOC)) { $subjarray[] = $rowsubj['subject_id'] ; } $arrlength = count($subjarray); for($x = 0; $x < $arrlength; $x++) { $subj = $subjarray[$x] ; //get the subject corressponding to subjarray elements $subjarray[$x] $subjskl = $DBcon->prepare("select subjectname from subjects where subject_id = :id ") ; $subjskl->bindparam(':id' , $subj) ; $subjskl->execute() ; $rowpsubj = $subjskl->FETCH(PDO::FETCH_ASSOC) ; $realsubject = $rowpsubj['subjectname'] ; //echo $realsubject; //get firsterm total for the subject in question: $firsttermquery = $DBcon->prepare("select * from marks where (acad_session = :yr and subject_id = :id) and (term = 'FIRST TERM' AND stregno = :reg)" ) ; $firsttermquery->bindparam(':yr' , $schyear) ; $firsttermquery->bindparam(':id' , $subj) ; $firsttermquery->bindparam(':reg' , $regno) ; $firsttermquery->execute() ; //$exfirst = mysql_query($firsttermquery) ; $nr1 = $firsttermquery->rowcount() ; if($nr1 > 0) { $rowfirst = $firsttermquery->FETCH(PDO::FETCH_ASSOC) ; $firsttest = $rowfirst['test'] ; $firstmidterm = $rowfirst['midterm'] ; $firstexam = $rowfirst['exam'] ; $firsttotal = $firsttest + $firstmidterm + $firstexam ; $firsttot[] = $firsttotal ; } else $firsttotal = '-' ; //end of firsterm // get second term total $secondtermquery =$DBcon->prepare("select * from marks where (acad_session = :yr and subject_id = :id) and (term = 'SECOND TERM' AND stregno = :reg)") ; $secondtermquery->bindparam(':yr' , $schyear) ; $secondtermquery->bindparam(':id' , $subj) ; $secondtermquery->bindparam(':reg' , $regno) ; $secondtermquery->execute() ; //$exsecond = mysql_query($secondtermquery) ; $nr2 = $secondtermquery->rowcount() ; if($nr2 > 0) { $rowsecond = $secondtermquery->FETCH(PDO::FETCH_ASSOC) ; $secondtest = $rowsecond['test'] ; $secondmidterm = $rowsecond['midterm'] ; $secondexam = $rowsecond['exam'] ; $secondtotal = $secondtest + $secondmidterm +$secondexam; $secondtot[] = $secondtotal ; } else $secondtotal = '-' ; //end of end of second term total // get third term $thirdtermquery =$DBcon->prepare("select * from marks where (acad_session = :yr and subject_id = :id) and (term = 'THIRD TERM' AND stregno = :reg)") ; $thirdtermquery->bindparam(':yr' , $schyear) ; $thirdtermquery->bindparam(':id' , $subj) ; $thirdtermquery->bindparam(':reg' , $regno) ; $thirdtermquery->execute() ; //$exthird = mysql_query($thirdtermquery) ; $nr3 = $thirdtermquery->rowcount() ; if($nr3 > 0) { $rowthird = $thirdtermquery->FETCH(PDO::FETCH_ASSOC) ; $thirdtest = $rowthird['test'] ; $thirdmidterm = $rowthird['midterm'] ; $thirdexam = $rowthird['exam'] ; $thirdtotal = $thirdtest + $thirdmidterm + $thirdexam ; $thirdtot[] = $thirdtotal ; } else { $thirdtotal = '-' ; $grade = '-' ; } //get third term grade if(!isset($grade)) { if ($thirdtotal <= $fe) { $grade = 'F' ; //$comment = 'FAIL' ; } elseif( ($thirdtotal >= $ps) && ($thirdtotal <= $pe) ) { $grade = 'P' ; // $comment = 'PASS' ; } elseif( ($thirdtotal >= $cs) && ($thirdtotal <= $ce) ) { $grade = 'C' ; //$comment = 'CREDIT' ; } elseif( ($thirdtotal >= $gs) && ($thirdtotal <= $ge) ) { $grade = 'B' ; //$comment = 'CREDIT' ; } elseif( ($thirdtotal > $as) && ($thirdtotal <= $ae) ) { $grade = 'A' ; //$comment = 'DISTINCTION' ; } else $grade = '-' ; } //end of grade //get cumulative total //if(!isset($firsttotal)) $firsttotal = 0 ; //if(!isset($secondtotal)) $secondtotal = 0 ; //if(!isset($thirdtotal)) $thirdtotal = 0 ; if(($firsttotal > 0) and ($secondtotal > 0) and ($thirdtotal > 0)) { $ta = $firsttotal + $secondtotal + $thirdtotal ; $cumavg = $ta / 3 ; } elseif(($firsttotal == 0) and ($secondtotal == 0) and ($thirdtotal > 0)) { $ta = $thirdtotal ; $cumavg = $ta / 1 ; } elseif(($firsttotal == 0) and ($secondtotal == 0) and ($thirdtotal == 0)) { $ta = '-' ; $cumavg = '-' ; } elseif(($firsttotal > 0) and ($secondtotal == 0) and ($thirdtotal == 0)) { $ta = $firsttotal ; $cumavg = $ta / 1 ; } elseif(($firsttotal == 0) and ($secondtotal > 0 ) and ($thirdtotal == 0)) { $ta = $secondtotal ; $cumavg = $ta / 1 ; } elseif(($firsttotal > 0 ) and ($secondtotal > 0 ) and ($thirdtotal == 0)) { $ta = $firsttotal + $secondtotal ; $cumavg = $ta / 2 ; } elseif(($firsttotal == 0) and ($secondtotal > 0) and ($thirdtotal > 0)) { $ta = $thirdtotal + $secondtotal ; $cumavg = $ta / 2 ; } elseif(($firsttotal > 0) and ($secondtotal == 0) and ($thirdtotal > 0)) { $ta = $firsttotal + $thirdtotal ; $cumavg = $ta / 2 ; } //$cumt = $firsttotal + $secondtotal + $thirdtotal ; //end //get cumulative Average //$cumavg = $ta / 3 ; //end //get cumulative grade if ($cumavg >= 70.00) { $cumg = 'A' ; } elseif(($cumavg >= 60.00) and ($cumavg <= 69.99)) { $cumg = 'B' ; } elseif(($cumavg >= 50.00) and ($cumavg <= 59.99)) { $cumg = 'C' ; } elseif(($cumavg >= 40.00) and ($cumavg <= 49.99)) { $cumg = 'P' ; } elseif(($cumavg >= 00.00) and ($cumavg <= 39.99)) { $cumg = 'F' ; } //end echo "" ; echo "" ; if((isset($firsttotal)) and ($firsttotal <> 0)) echo "" ; else echo "" ; if((isset($secondtotal)) and ($secondtotal <> 0)) echo "" ; else echo "" ; ?> 0)) //echo "" ; //else //echo "" ; ?> 0)) //echo "" ; //else //echo "" ; ?> 0)) //echo "" ; //else //echo "" ; echo "" ; //if((isset($thirdtoal)) and ($thirdtotal <> 0)) //echo "" ; //else //echo "" ; if((isset($ta)) and ($ta <> 0)) echo "" ; else echo "" ; if((isset($cumavg)) and ($cumavg <> 0)) echo "" ; else echo "" ; if((isset($cumavg)) and ($cumavg <> 0)) echo "" ; else echo "" ; echo "" ; if(isset($thirdtest) and ($thirdtest > 0)) $thirdtest = null ; if(isset($thirdmidterm) and ($thirdmidterm > 0)) $thirdmidterm = null ; if(isset($thirdexam) and ($thirdexam > 0)) $thirdexam = null ; $grade = null ; } ?>
SUBJECTS 1ST TERM 2ND TERM
THIRD TERM
TOTAL(300) AVG GRADE
".$realsubject."".$firsttotal."".'-'."".$secondtotal."".'-'."".$thirdtest."".'-'."".$thirdmidterm."".'-'."".$thirdexam."".'-'."".$thirdtotal."".$grade."".'-'."".$ta."".'-'."".round($cumavg,2)."".'-'."".$cumg."".'-'."
Key To Grades : 70% and above : Excellent , 60-69% : Good, 50% to 59%  : Credit , 40%- 49% : Pass, 0% to 39% : Fail

   0) //echo $ts; // else // echo '-' ; ?>      prepare("select * from subjno where (classlevel = :kls and term = :tm) and yr = :y ") ; $sqlm3->bindparam(':kls' , $stclass) ; $sqlm3->bindparam(':tm' , $term3) ; $sqlm3->bindparam(':y',$schyear) ; $sqlm3->execute() ; $rowm3 = $sqlm3->FETCH(PDO::FETCH_ASSOC) ; $min3 = $rowm3['nos'] ; $avgq = $DBcon->prepare("select * from marks where (acad_session =:yr and stclass =:kls) and (term = :tm AND stregno = :reg)") ; $avgq->bindparam(':yr' , $schyear) ; $avgq->bindparam(':kls' , $classid) ; $avgq->bindparam(':tm' , $term3) ; $avgq->bindparam(':reg' , $regno) ; $avgq->execute() ; $num3 =$avgq->rowcount() ; if($num3 > 0) { $count3 = array_sum($thirdtot) ; if($num3 < $min3) $avg3 = $count3 / $min3 ; else $avg3 = $count3 / $num3 ; //echo round($avg3,2) ; } else { $avg3 = '-' ; //echo $avg3 ; } ?>  prepare("select * from marks where (stclass = :kls and acad_session = :yr) and (stregno = :reg ) ") ; $so->bindparam(':kls' , $classid) ; $so->bindparam(':yr' , $schyear) ; $so->bindparam(':reg' , $regno) ; //$so->bindparam(':tm' , $term) ; $so->execute() ; //$res = mysql_query($so) or die('Error: ' . mysql_error()) ; while ($ro = $so->FETCH(PDO::FETCH_ASSOC)) { $fst = $ro['test'] ; $sc = $ro['midterm'] ; $exa = $ro['exam'] ; $tom = $fst + $sc + $exa ; $maya[] = $tom ; } $cal = array_sum($maya) ; //start $streamno = array(); $arresult = array() ; $myarray = array() ; //$finarray = array() ; $sqla = $DBcon->prepare("select distinct stregno from marks where (stclass =:kls and acad_session =:yr) " ) ; $sqla->bindparam(':kls',$classid) ; $sqla->bindparam(':yr',$schyear) ; //$sqla->bindparam(':tm',$term) ; $sqla->execute() ; //$exec = mysql_query($sqla) or die('Error: ' . mysql_error()); //$row = mysql_fetch_array($exec) ; while ($streamrow = $sqla->FETCH(PDO::FETCH_ASSOC)) { $streamno[] = $streamrow['stregno']; } foreach ($streamno as $val) { $sqlgo =$DBcon->prepare("select * from marks where ((stregno = :v and stclass = :kls) and (acad_session = :yr)) ") ; $sqlgo->bindparam(':v',$val) ; $sqlgo->bindparam(':kls',$classid) ; //$sqlgo->bindparam(':tm',$term) ; $sqlgo->bindparam(':yr',$schyear) ; $sqlgo->execute() ; //$go = mysql_query($sqlgo) or die('Error: ' . mysql_error()); //$gorow = mysql_fetch_array($go) ; $rownumber = $sqlgo->rowcount() ; while ($gorow = $sqlgo->FETCH(PDO::FETCH_ASSOC)) { $first = $gorow['test'] ; $sec = $gorow['midterm'] ; $ex = $gorow['exam'] ; $tota = $first + $sec + $ex ; $myarray[] = $tota ; //$myarray[] = $ar ; } $tosum = array_sum($myarray) ; if($rownumber < $min) $ar = $tosum/$min ; else $ar = $tosum/$rownumber; $arresult[] = $ar ; $myarray = array() ; } arsort($arresult) ; $ps = 0 ; foreach($arresult as $tot) { $ps++ ; $app = position($ps) ; if($avg3 == $tot) { //echo $ps.$app ; break ; } } ?>

Cumulative Grade: Total Score: Average Score: prepare("select * from subjno where (classlevel = :kls and term = :tm) and yr = :y ") ; $sqlm1->bindparam(':kls' , $stclass) ; $sqlm1->bindparam(':tm' , $term1) ; $sqlm1->bindparam(':y',$schyear) ; $sqlm1->execute() ; $rowm1 = $sqlm1->FETCH(PDO::FETCH_ASSOC) ; $min1 = $rowm1['nos'] ; $avgq1 =$DBcon->prepare("select * from marks where (acad_session = :yr and stclass = :kls) and (term = 'FIRST TERM' AND stregno = :reg)") ; $avgq1->bindparam(':yr',$schyear) ; $avgq1->bindparam(':kls',$classid) ; $avgq1->bindparam(':reg',$regno) ; $avgq1->execute() ; //$exavgq1 = mysql_query($avgq1) ; $num1 = $avgq1->rowcount(); if($num1 > 0) { $count1 = array_sum($firsttot) ; if($num1 < $min1) $avg1 = $count1 / $min1 ; else $avg1 = $count1 / $num1 ; } else $avg1 = '-' ; // get second term average //get minimum no of subject $term2 = "SECOND TERM" ; $sqlm2 = $DBcon->prepare("select * from subjno where (classlevel = :kls and term = :tm) and yr = :y ") ; $sqlm2->bindparam(':kls' , $stclass) ; $sqlm2->bindparam(':tm' , $term2) ; $sqlm2->bindparam(':y',$schyear) ; $sqlm2->execute() ; $rowm2 = $sqlm2->FETCH(PDO::FETCH_ASSOC) ; $min2 = $rowm2['nos'] ; $avgq2 =$DBcon->prepare("select * from marks where (acad_session = :yr and stclass = :kls) and (term ='SECOND TERM' AND stregno = :reg)") ; $avgq2->bindparam(':yr',$schyear) ; $avgq2->bindparam(':kls',$classid) ; $avgq2->bindparam(':reg',$regno) ; $avgq2->execute() ; //$exavgq2 = mysql_query($avgq2) ; $num2 = $avgq2->rowcount() ; if($num2 > 0) { $count2 = array_sum($secondtot) ; if($num2 < $min2) $avg2 = $count2 / $min2 ; else $avg2 = $count2 / $num2 ; } else $avg2 = '-' ; if(($avg1 == '-') and ($avg2 == '-') and ($avg3 == '-')) { $cuv = '-' ; } elseif(($avg1 == '-') and ($avg2 == '-') and ($avg3 > 0)) { $cuv = $avg3 ; } elseif(($avg1 > 0) and ($avg2 > 0) and ($avg3 > 0)) { $cumavgt = $avg1 + $avg2 + $avg3 ; $cuv = $cumavgt / 3 ; } elseif(($avg1 > 0) and ($avg2 == '-') and ($avg3 == '-')) { $cuv = $avg1 ; } elseif(($avg1 == '-') and ($avg2 > 0 ) and ($avg3 == '-')) { $cuv = $avg2 ; } elseif(($avg1 > 0 ) and ($avg2 > 0 ) and ($avg3 == '-')) { $cumavgt = $avg1 + $avg2 ; $cuv = $cumavgt / 2 ; } elseif(($avg1 == '-') and ($avg2 > 0) and ($avg3 > 0)) { $cumavgt = $avg3 + $avg2 ; $cuv = $cumavgt / 2 ; } elseif(($avg1 > 0) and ($avg2 == '-') and ($avg3 > 0)) { $cumavgt = $avg1 + $avg3 ; $cuv = $cumavgt / 2 ; } //$cuv = $cumavgt / 3 ; echo round($cuv, 2) ; ?> Position: prepare("select * from marks where (stregno = :reg and acad_session = :yr) and stclass =:kls ") ; $so->bindparam(':reg',$regno) ; $so->bindparam(':yr',$schyear) ; $so->bindparam(':kls',$classid) ; $so->execute() ; //$res = mysql_query($so) or die('Error: ' . mysql_error()) ; $rn = $so->rowcount(); while ($ro = $so->FETCH(PDO::FETCH_ASSOC)) { $fst = $ro['test'] ; $snd = $ro['midterm'] ; $exa = $ro['exam'] ; $tom = $fst + $snd + $exa ; $maya[] = $tom ; } $cal = array_sum($maya) ; $av1 = $cal / $rn ; //start $streamno = array(); $arresult = array() ; $myarray = array() ; //$finarray = array() ; $sqla =$DBcon->prepare("select distinct stregno from marks where (stclass = :kls and acad_session = :yr) ") ; $sqla->bindparam(':kls',$classid) ; $sqla->bindparam(':yr',$schyear) ; $sqla->execute(); while ($streamrow = $sqla->FETCH(PDO::FETCH_ASSOC)) { $streamno[] = $streamrow['stregno']; } foreach ($streamno as $val) { $sqlgo = $DBcon->prepare("select * from marks where(stregno = :v and acad_session = :yr) ") ; $sqlgo->bindparam(':v',$val) ; $sqlgo->bindparam(':yr',$schyear) ; $sqlgo->execute(); //$go = mysql_query($sqlgo) or die('Error: ' . mysql_error()); $rownumber = $sqlgo->rowcount() ; //$gorow = mysql_fetch_array($go) ; while ($gorow = $sqlgo->FETCH(PDO::FETCH_ASSOC)) { $first = $gorow['test'] ; $sec = $gorow['midterm'] ; $ex = $gorow['exam'] ; $tota = $first + $sec + $ex ; $myarray[] = $tota ; } $tosum = array_sum($myarray) ; $ar = $tosum/$rownumber; $arresult[] = $ar ; // $arresult[] = $tosum ; $myarray = array() ; } arsort($arresult) ; $ps = 0 ; foreach($arresult as $tot) { $ps++ ; $ap = position($ps) ; if($av1 == $tot) { echo $ps.$ap ; break ; } } ?> Out of

 
Principal's Remark : = 40) and ($cuv <= 49.99)) echo 'WEAK PASS, PROMOTED ' ; elseif($cuv >= 50.00) echo 'PASS, PROMOTED' ; ?>
Next Term Fees:
Next Term Begins on:
prepare("select * from pinassociate where (PINCODE = :p and TERM = :tm) and acadsession = :yr " ); $sqlp->bindparam(':p',$pin) ; $sqlp->bindparam(':tm',$term) ; $sqlp->bindparam(':yr',$schyear) ; $sqlp->execute(); if($sqlp->rowcount() > 0) { $row1 = $sqlp->FETCH(PDO::FETCH_ASSOC) ; $upin = $row1['PINCODE'] ; $owner = $row1['REGNO'] ; $numbused = $row1['NOUSED'] ; $yr = $row1['acadsession'] ; $newno = $numbused + 1 ; $updateno =$DBcon->prepare("update pinassociate set NOUSED = :n where PINCODE = :u") ; $updateno->bindparam(':n',$newno) ; $updateno->bindparam(':u',$upin) ; $updateno->execute() ; //$upchange = mysql_query($updateno) or die('Error: ' . mysql_error()); } else // this is a new pin, insert it and the student data to pin associate { $insertaso =$DBcon->prepare("insert into pinassociate(REGNO,NOUSED,PINCODE,TERM,acadsession) values(:reg,1,:p,:tm,:yr)") ; $insertaso->bindparam(':reg',$regno) ; $insertaso->bindparam(':p',$pin) ; $insertaso->bindparam(':tm',$term) ; $insertaso->bindparam(':yr',$schyear) ; $insertaso->execute() ; //$newpin = mysql_query($insertaso) or die('Error: ' . mysql_error()); }//end pin check ?>