<?php 

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

if (isset($_POST['matricno'])) {
   
    $session = $_POST['session'];
    $level = $_POST['level'];
    $semester = $_POST['semester'];
    $matricno = $_POST['matricno'];
   
    
    // $query = "SELECT course_code, course_title, course_unit FROM tbl_courses 
				// WHERE department = '$dept' AND   level = '$level' AND semester = '$semester'";
				
	   // $result = mysql_query($query);
	  //echo "Substr: ".substr($matricno,0,2);
	   //if (substr($matricno,0,2)=='')
				
    // $result = $database->query($qry);
   $find=array();
     $cinfo =  coursedetails($session, $level,$semester);
     $find= explode(',',$cinfo);
     
     $result = ONLINEPAY::findstucourse($find[0],$matricno);
     
    $count=0;
     $_SESSION['tbl']= $find[0];
     $_SESSION['sem']=$find[1];
      $_SESSION['matricno']=$matricno;
      
      
        // <form method="post" action="eportal.oscotechesaoke.edu.ng/admin_portal1/dashboard.php?type=printingform">
   
   $i=0;
   if ((isset($succ)) && (isset($_SESSION['matricno']))){
       
   }else {
   echo '<form method="post" action=""><table class="table table-striped table-bordered">
 
			                <tr>
			                    <th>Matric No</th>  
			                    <th>Semester</th>  
			                    <th>Department</th>
			                    <th>Courses</th>
								<th>Select</th>
								<th>Delete</th>
			                </tr>
			        	';

    foreach ($result as $res) {
       
        $_SESSION['count']= $count++;
        $i++;
        echo '<tr>'
            . '<td>' . $res->matricno . '</td>'
            . '<td>' . $res->ses_sem_id . '</td>'
            . '<td>' . $res->department . '</td>'
            . '<td>' . $res->courses . '</td>'
            . '<td>'. '<input type="submit" name="'.'update'.$i.'" class="btn btn-info" id="'.'update'.$i.'" value="Update">'.'</td>'
            // <td><button type="button" name="delete" class="btn btn-danger btn-xs delete" id="'.$row->id.'">Delete</button></td>


            .'<td>'. '<input type="submit" name="'.'delete'.$i.'" class="btn btn-danger btn-xs delete" id="'.'delete'.$i.'" value="Delete">'. '</td></tr>';
    }
    echo '</form></table>';
    
   }
    
} 

else {
    echo 'No POST';
} 


?>