Sure here's the code:
<?
include ('data.php3');
function tab($word,$length)
{
$totalWord = "";
$wordTrimed = trim($word);
$totalWord .= trim($word);
for($i = strlen($wordTrimed); $i <$length;$i++)
{
$totalWord.=" ";
}
$totalWord.="|";
return $totalWord;
}
$file = fopen("student_schedules.xqb", "w");
$students = d_load_all_students();
$count = count($students);
$wholeline = "\n------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n";
for($i = 0; $i < $count;$i++)
//for($i = 0; $i <300;$i++)
{
$singleStudent = "";
$row = $students[$i];
$hrm = $row['homeroom'];
$name = $row['text'];
$grade = $row['grdlvl'];
$id = $row['id'];
$singleStudent .=tab($name,'30');
$singleStudent .="|";
$classes = d_get_students_classes($id, "1"); //first half first semester
$classes2 = d_get_students_classes($id, "2"); //second half first semester
$classes3 = d_get_students_classes($id, "3"); //first half second semester
$classes4 = d_get_students_classes($id, "4"); //second half second semester
for($j = 1 ; $j <= 5;$j++) //counts from first class to fifth class for sem 1
{
$info = $classes[$j];
$code = $info['code'];
$singleStudent.=tab($code, '15');
}
for($j = 1 ; $j <=4;$j++) //counts from first class to fifth class for sem 2
{
$info = $classes3[$j];
$code = $info['code'];
$singleStudent.=tab($code, '15');
}
$singleStudent .="\n";
$singleStudent .=tab($hrm, '30');
$singleStudent .="|";
for($j = 1; $j <=5; $j++) //count for 1st class to 5th class for sem 1
{
$info = $classes[$j];
$checkInfo = $classes2[$j];
$room = $info['room'];
$code = $info['code'];
$codeCheck = $checkInfo['code'];
if($code != $codeCheck)
{
$room2nd = $checkInfo['room'];
$length = 15-strlen($room2nd)-strlen($room);
$singleStudent.= "$room";
for($k = 0; $k<$length;$k++)
{
$studentStudent.=" ";
}
$singleStudent.="$room2nd";
$singleStudent.= "|";
}
else
{
$singleStudent .= tab($room,'15');
}
}
for($j = 1; $j <=4; $j++) //count 1st class to 4th class for sem 1
{
$checkInfo = $classes4[$j];
$info = $classes3[$j];
$room = $info['room'];
$code = $info['code'];
$codeCheck = $checkInfo['code'];
if($code != $codeCheck)
{
$room2nd = $checkInfo['room'];
$length = 15-strlen(room2nd);
$singleStudent.=$room;
for($k = 0; $k<$length;$k++)
{
$singleStudent.=" ";
}
$singleStudent.=$room2nd;
}
else
{
$singleStudent.=tab($room,'15');
}
}
$singleStudent.="\n";
$singleStudent.=tab($grade , '30');
$singleStudent.="|";
for($j = 1; $j <= 5; $j++)
{
$info = $classes[$j];
$code = $info['code'];
$teacher_id = d_get_teacherid_from_classcode_only($code);
$teacher = d_get_teacher_from_id($teacher_id);
$checkInfo = $classes2[$j];
$checkCode = $checkInfo['code'];
if($checkCode!=$code)
{
for($k = 0; $k < 15-strlen($checkCode);$k++)
{
$singleStudent.=" ";
}
$singleStudent.=$checkCode;
$singleStudent.="|";
}
else
{
$singleStudent.=tab($teacher, '15');
}
}
for($j = 1; $j <=4; $j++)
{
$info = $classes3[$j];
$code = $info['code'];
$teacher_id = d_get_teacherid_from_classcode_only($code);
$teacher = d_get_teacher_from_id($teacher_id);
$checkInfo = $classes4[$j];
$checkCode = $checkInfo['code'];
if($checkCode!=$code)
{
for($k = 0; $k < 15-strlen($checkCode);$k++)
{
$single_student.=" ";
}
$singleStudent.= $checkCode;
$singleStudent.="|";
}
else
{
$singleStudent.=tab($teacher, '15');
}
}
$singleStudent.=$wholeline;
fputs($file,"$singleStudent",strlen($singleStudent));
set_time_limit(60);
}
fclose($file);
?>