Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 学生使用codeigniter在考场分发_Php_Mysql_Codeigniter 3 - Fatal编程技术网

Php 学生使用codeigniter在考场分发

Php 学生使用codeigniter在考场分发,php,mysql,codeigniter-3,Php,Mysql,Codeigniter 3,我有三张学生桌,第一张是卷号 二是中心细节 三是房间的细节 $anil = array(); $exam_no_students = array(); $session_usr['user']= $this->session->userdata('user_name'); $total_students['total_stu']=$this->DBfunction->totalCountAll('roll_no'); $exam_centers['no_of_cent

我有三张学生桌,第一张是卷号

二是中心细节

三是房间的细节

$anil = array();
$exam_no_students = array();
$session_usr['user']= $this->session->userdata('user_name');
$total_students['total_stu']=$this->DBfunction->totalCountAll('roll_no');
$exam_centers['no_of_centers']= $this->DBfunction->count_centers();
$exam_centers1= $this->DBfunction->count_centers();
foreach ($exam_centers1 as $center_code => $center_details){
        $center_code = array('center_id' =>$center_details->center_id);
        $center_table='exam_center';
        $center_full_details =$this->DBfunction->getArrayWhereResult($center_table,$center_code);
        foreach ($center_full_details as $full => $full_de) {
                $fullstudent = array('center_f_id' =>$full_de->center_id,
                'center_f_name' =>$full_de->exam_center,
                'center_f_addres' =>$full_de->exam_center_address ,
                'center_f_city' =>$full_de->village ,
                'center_f_count' =>$center_details->count);                             
                }
                array_push($exam_no_students, $fullstudent);
                $center_f_details =$this->DBfunction->getArrayWhereResult($center_table,$center_code);
                foreach ($center_f_details as $roomss => $rooms) {
                $room_id = array('exam_center_id' =>$rooms->id);
                $center_rooms =$this->DBfunction->getArrayWhereResult('exam_center_rooms',$room_id);
                foreach ($center_rooms as $rooms_c => $roomsdetails) {
                $center_with_rooms['anil'] = array('center_id'=>$rooms->center_id,                                                              
                'center_name'=>$rooms->exam_center,                                                             
                'center_main'=>$roomsdetails->exam_center_id,                                                               
                'no_of_students'=>$center_details->count,                                                               
                'room_no'=>$roomsdetails->room_no,                                                              
                'no_of_seating'=>$roomsdetails->noofseating,                                                                'noofrow'=>$roomsdetails->noofrow,                                                              
                'noofcol'=>$roomsdetails->noofcol
                );
   }
}

我想把学生分配到下表所示的房间进行考试


我对此感到非常困惑。

我使用array_slice()获得了上述查询的解决方案。并取得了预期的效果

public function Student_shift(){
            $stateus='Approved';
            $statuss = array('status' =>$stateus);
            $table ='exam_center';
            $get_centers=$this->DBfunction->getArrayWhereResult($table,$statuss);
            $new_array = array();
            foreach ($get_centers as $centers => $centers_name){
                $i=1;
                $centerid=$centers_name->center_id;
                $main_id = $centers_name->id;
                $center_where = array('center_id' =>$centerid); 
                $roll_table='roll_no';
                $all_center_student = $this->DBfunction->getArrayWhereResult($roll_table,$center_where);
                $all_center_student_count=count($all_center_student);//die;                 
                $rooms_where = array('exam_center_id' =>$main_id);
                    $room_table= 'exam_center_rooms';
                    $rooms_details= $this->DBfunction->getArrayWhereResult($room_table, $rooms_where);
                    $cout = count($all_center_student);
                    $diff_diff=$all_center_student;
                    $start =0;
                    $shift=1;
                    $rooms_seating = 0; 
                    while ($diff_diff){
                        $start =0;
                        $rooms_seating = 0;
                        $i=0;
                        ini_set('max_execution_time', 0); 
                        ini_set('memory_limit','2048M');
                    foreach ($rooms_details as $roo => $rooms_ava){                         
                         $sliced_array = array_slice($diff_diff, $start, $rooms_ava->noofseating-2);
                        $start = $rooms_ava->noofseating-2;                                                     
                            foreach ($sliced_array as $key1 => $all) {
                            $students_with_rooms = array('enrollment' =>$all->enrollment,
                                                        'center_id' =>$all->center_id,
                                                        'roll_no' =>$all->roll_no,
                                                        'stu_class' =>$all->stu_class,
                                                        'room_no' =>$rooms_ava->room_no,
                                                        'shift_id'=>$shift                                  
                             );                                 
                             $roll_where = array('roll_no' => $all->roll_no);
                             $table='roll_no';  
                             $data = array('room_no' => $rooms_ava->room_no,
                                            'shift_id'=>$shift
                            );  
                            $this->DBfunction->updateArrayWhereResult($table, $roll_where, $data);                          
                            array_push($new_array, $students_with_rooms);
                            }   
                            $rooms_seating = $rooms_seating+$rooms_ava->noofseating-2;  
                            $i++;                       
                     }
                     $diff_diff = array_slice($diff_diff, $rooms_seating);
                     $shift++;
                }                   
         }
         redirect('Admin/abcd');
    }

从链接添加图像