<?php 
require_once("includes/initialize.php");
global $database;global $connection;

if (isset($_POST['semester'])) {
    $matric = $_POST['matricno'];
    $code = $_POST['course_code'];
    $level = $_POST['level'];
    $semester = $_POST['semester'];
   
    switch(strtoupper($level).$semester){
        
        case 'ND I'.'First':
            $table='ndi_tbl';
            $semid=1;
            $prev='ND I';
            break;
        case 'ND I'.'Second':
            $table='ndi_tbl';
            $semid=2;
            $prev='ND I';
            break;
         case 'HND I'.'First':
            $table='hndi_tbl';
            $semid=1;
            $prev='HND I';
            break;
        case 'HND I'.'Second':
            $table='hndi_tbl';
            $semid=2;
            $prev='HND I';
            break;
        case 'ND II'.'First':
            $table='ndii_tbl';
            $prev='ND I';
            $semid=3;
            break;
        case 'ND II'.'Second':
            $table='ndii_tbl';
             $prev='ND I';
            $semid=4;
            break;
         case 'HND II'.'First':
            $table='hndii_tbl';
            $prev='HND I';
            $semid=3;
            break;
        case 'HND II'.'Second':
            $table='hndii_tbl';
            $prev='HND I';
            $semid=4;
            break;
            
        default:
            die('Invalid record record selection');
        
        
    }
    
   
    
   //echo $table.' '. $matric.' '.$semid.' '.$code;
    $result = COURSECLASS::update_courses($table, $matric, $semid,$code);
    if (!$result){
        $output= "Update failed";
    }else{
        
   $output= "Record updated successfully";
  
} 

echo $output;

// $allarray=array($allcourses,$allcourses2);
// print_r($allarray);
}
else {
    echo 'No POST';
} 


?>