prepare('select * from subjects') ;
$gts->execute() ;
$subject = array() ;
$sid = array() ;
while($row = $gts->fetch(pdo::FETCH_ASSOC))
{
$subject[] = $row['subjectname'] ;
$sid[] = $row['subject_id'] ;
}
$lenght = count($subject) ;
if(isset($_POST['submit']))
{
$reg = $_POST['reg'];
//check if the student result has bee upload before
$chk = $DBcon->prepare("select * from marks where((stregno =:a and acad_session =:b) and (term =:c and stclass =:d))") ;
$chk->bindparam(":a",$reg) ;
$chk->bindparam(":b",$acyear) ;
$chk->bindparam(":c",$schterm) ;
$chk->bindparam(":d",$classid) ;
$chk->execute() ;
if($chk->rowcount() > 0)
{
$mes = "this student result for this term has been uploaded before, upload another one" ;
}
else
{
for($x = 0; $x < $lenght; $x++)
{
//echo "value : ".$value.'
';
$test = $_POST['test'][$x] ;
$test2 = $_POST['test2'][$x] ;
$exam = $_POST['exam'][$x] ;
$subjid = $sid[$x] ;
if(empty($test)) $test = 0;
if(empty($test2)) $test2 = 0;
if(empty($exam)) $exam = 0;
if(($test == 0) and ($test2 == 0) and ($exam == 0))
{
//do nothing
}
else
{
$sql = $DBcon->prepare("insert into marks(stregno,acad_session,term,subject_id,stclass,test,midterm,exam) values(:a,:b,:c,:d,:e,:l,:g,:h)");
$sql->bindparam(":a",$reg) ;
$sql->bindparam(":b",$acyear) ;
$sql->bindparam(":c",$schterm) ;
$sql->bindparam(":d",$subjid) ;
$sql->bindparam(":e",$classid) ;
$sql->bindparam(":l",$test) ;
$sql->bindparam(":g",$test2) ;
$sql->bindparam(":h",$exam) ;
if($sql->execute()) $mes = 'Published succesfully' ;
}
}
}
}
?>
| Uploading |