if ($result1 && ($info1 = $result1->fetch_array())) { $sql2 = "select * from teacher where teacher_id = '{$info1['1']}'"; //获取教师名 $result2 = $conn->query($sql2); if ($result2 && ($info2 = $result2->fetch_array())) { $class_array = explode('@', $info['course_class']); //班级信息分割成数组 //编辑专业班级字符串 $class = ""; for ($i = 0; $i < count($class_array); $i++) { $sql3 = "select student_major from student_information where student_number = substr({$class_array[$i]},1,6)"; //获取专业班级 $result3 = $conn->query($sql3); if ($result3) { $info3 = $result3->fetch_array(); $class = major_class($info3['student_major'], substr($class_array[$i], 0, 2) . '0' . substr($class_array[$i], 6, 1), $class); //$class = $info3['student_major'].substr($class_array[0],0,2).'0'.substr($class_array[0],6,1); } } echo $info['lock']; echo "<div class=\"course_text\">教师:" . $info2['teacher_name'] . "</div>"; echo "<div class=\"course_text\">课程:" . $info1['course_name'] . "</div>"; echo "<div class=\"course_text\">" . $class . "</div>"; echo "<div class=\"course_text\">备注:" . $info['tips'] . "</div>"; echo "@"; } else { echo 'error'; } } else { echo 'error'; }
function GetClassCol($conn, $course_class) { $class_array = explode('@', $course_class); //班级信息分割成数组 //编辑专业班级字符串 $class = ""; $class_array_length = count($class_array); for ($n = 0; $n < $class_array_length; $n++) { $sql3 = "select student_major from student_information where student_number = substr({$class_array[$n]}, 1, 6)"; //获取专业班级 $result3 = $conn->query($sql3); if ($result3) { $info3 = $result3->fetch_array(); $class = major_class($info3['student_major'], substr($class_array[$n], 0, 2) . '0' . substr($class_array[$n], 6, 1), $class); //$class = $info3['student_major'].substr($class_array[0],0,2).'0'.substr($class_array[0],6,1); } } return $class; }