如何根据特定时段的空缺分配老师?
例如:在第5班中,老师b在08:45 AM-09:30 AM时段分配,在其他班级中也是如此。代码如下:-
$get = isset($_GET['sch']) ? $_GET['sch'] : "school2" ;
$sql = "SELECT * FROM schools WHERE school = '$get' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
//echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
$totalPeriod = $row['total_period'];
$wdays = $row['working_days'];
$breaks = $row['no_of_breaks'];
$breaks_1st = $row['1st_break_alloted'];
$breaks_2nd = $row['2nd_break_alloted'];
$breaks_1st_duration = $row['1st_break_duration'];
$breaks_2nd_duration = $row['2nd_break_duration'];
$class_duration = $row['class-duration'];
$class_start = $row['class_start'];
}
} else {
echo "0 results";
}
if($wdays == 5){
$days = array("Monday", "Tuesday", "Wednesday", "Thusday", "Friday");
}else if($wdays == 6){
$days = array("Monday", "Tuesday", "Wednesday", "Thusday", "Friday", "Saturday");
}else{
echo "Working days not found";
}
$period = $totalPeriod + $breaks;
$class_start2 = $class_start;
$class_duration2 =$class_duration;
?>
<?php
$sql_cls_sec = "SELECT DISTINCT c_id FROM subjects ORDER BY c_id DESC ";
$result_cls_sec=mysqli_query($conn, $sql_cls_sec);
$row_cls_sec=mysqli_fetch_array($result_cls_sec);
$count_cls_sec=mysqli_num_rows($result_cls_sec);
$inserted_value = array("break", "break", "break","break","break");
$inserted_value2 = array("", "", "","","");
do{
$xxx=$row_cls_sec['c_id'];
$sql3 = "SELECT * FROM subjects WHERE c_id ='$xxx' ORDER BY class_teacher DESC ";
$result3 = $conn->query($sql3);
if ($result3->num_rows > 0) {
// output data of each row
// while($row3 = $result3->fetch_assoc()) {
// $sub_id[] = $row3['subject_id'];
// $w_class[] = $row3['w_c'];
// }
$row3 = $result3->fetch_assoc();
}
?>
<div class="col-sm-12 mt-3">
<h2 class="text-center">Class :- <?php echo $xxx; ?></h2>
<div class="d-flex flex-row bd-highlight ">
<div class="w-25 p-2 flex-fill border bd-highlight"></div>
<?php for($i=1; $i <= $period; $i++){
//echo "this-".$class_start2;
$time1 = date('h:i A', strtotime($class_start2));
if($i == $breaks_1st+1){
$class_duration2 = $breaks_1st_duration;
}else if(is_numeric($breaks_2nd) && $i == $breaks_2nd+2){
$class_duration2 = $breaks_2nd_duration;
}else{
$class_duration2 = $class_duration;
}
//$time2 = date('h:i A', strtotime($class_start)+($class_duration*60*$i));
$time2 = date('h:i A', strtotime($time1)+($class_duration2*60));
$class_start2 = $time2;
?>
<!-- <th scope="col"><?php //echo $time1." - ".$time2 ?></th> -->
<div class="p-2 flex-fill border bd-highlight text-center"><?php echo $time1." - ".$time2 ?></div>
<?php } ?>
<!-- <div class="p-2 flex-fill border bd-highlight">Flex item 1</div>
<div class="p-2 flex-fill border bd-highlight">Flex item 2</div> -->
</div>
<div class="row px-3" style="height:226px; ">
<div class="col-sm-2 p-0">
<div class="d-flex flex-column bd-highlight mb-3">
<?php foreach($days as $key => $value){ ?>
<div class="border p-2 "><?php echo $value ?></div>
<?php } ?>
</div>
</div>
<div class="col-sm-10 p-0">
<div class="d-flex flex-column flex-wrap bd-highlight mb-3" style="height:210px;">
<?php
//$counter=0;
do{
$sub_id= $row3['subject'];
$t_id= $row3['teacher'];
$wk_cls=$row3['w_c'];
//$wc=0;
for($i=1; $i <= $wk_cls; $i++){
//for($j=1; $j <= $day; $j++){
//echo $sub_id."</br>";
$sid[] = $sub_id;
$tid[] = $t_id;
?>
<!-- <div class="border p-2 "><?php //echo $sub_id ?></div> -->
<?php
//$counter++;
}
}while($row3 = $result3->fetch_assoc());
//shuffle($sid);
array_splice( $sid, 15, 0, $inserted_value );
array_splice( $sid, 30, 0, $inserted_value );
array_splice( $tid, 15, 0, $inserted_value2 );
array_splice( $tid, 30, 0, $inserted_value2 );
//echo "After inserting 11 in the array is : </br>";
for($s=0; $s < count($sid); $s++)
{
//echo $x."</br>";
?>
<div class="border p-2 "><?php echo $sid[$s] ?> - <?php echo $tid[$s] ?></div>
<?php
}
?>
</div>
</div>
</div>
</div></br>
<?php
unset($sid);
unset($x);
unset($tid);
//unset($class_start2);
$class_start2 = $class_start;
}while($row_cls_sec=mysqli_fetch_array($result_cls_sec));
?>
现在,如何在另一个时间段分配一位老师?
我必须使用javascript吗?
请帮助我,谢谢。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。