<div class="container bg-white mt-3 mb-3 pt-3 pb-3">
    <div class="row">
        <div class="col-sm-12">
            
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>Sid</th>
                        <th>Name</th>
                        <th>Father Name</th>
                        <th>Class</th>
                        <th>New Class</th>
                    </tr>
                </thead>
                
                <tbody>
                    <tr>

                    </tr>

<?php
$course=$this->uri->segment('3');
$acedemic_session=$this->session->userdata('acedemic_session');
$new_acedemic_session=2;
$new_ac_year='2021-2022';
$count=0;
$new_course='';
$student_table='student';
$student_course_table='student_courses_data';
$get_all_course_students=$this->WelcomeModel->get_course_students_by_ac_session($acedemic_session,$course);
if($get_all_course_students){
    foreach($get_all_course_students as $course_students){
        $count=$count + 1;
        $sid=$course_students['sid'];
        $get_student_info=$this->WelcomeModel->get_item_data($sid,$student_table);
        if($get_student_info){
            foreach($get_student_info as $student_info){
        echo "<tr>";
        echo "<td>".$count."</td>";
        echo "<td>".$sid."</td>";
        echo "<td>".$student_info['student_name']."</td>";
        echo "<td>".$student_info['father_name']."</td>";
        echo "<td>".$course_students['class']."</td>";
        
        
        if($course == 'PG'){
            $new_course='LKG';
        }else if($course == 'LKG'){
            $new_course='UKG';
        }else if($course=='UKG'){
            $new_course='1';
        }else if($course <=11){
            $new_course=$course + 1;
        }
        
        $check_student_in_courses_data=$this->WelcomeModel->get_student_in_acedemic_session($sid,$new_acedemic_session);
        if($check_student_in_courses_data){
            
        }else{
            $data_array=array("acedemic_session"=>$new_acedemic_session,"class"=>$new_course,"ac_year"=>$new_ac_year,"sid"=>$sid);
            $add_student_in_course_data=$this->WelcomeModel->insert_data($data_array,$student_course_table);
            if($add_student_in_course_data){
                
            }
        }
        
        // echo $new_course;
        echo "<td>".$new_course."</td>";
        echo "</tr>";
            }
        }
    }
}    

?>
                </tbody>
            </table>            

        </div>
    </div>
</div>