function getOfferingTimeTable($sid) { $temp = getStu_offeringBySid($sid); $timeTable = array(); //#1.遍历该学生所选的offering,将该学生的课程时间放入一个临时的表里 while ($row = mysql_fetch_array($temp)) { //print_r($row); $offeringResult = getOfferingById($row['oid']); $offeringRow = mysql_fetch_array($offeringResult); // print_r($offeringRow); $timeTable = setOfferingTimeTable($offeringRow, $timeTable); } return $timeTable; }
} ?> <a href="javascript:history.back()">back</a> <a href="displayCourse.php">home page</a> <!--</div>--> </p> <?php } else { //echo "xx"; $temp = getStu_offeringBySid($sid); $timeTable = array(); //#1.遍历该学生所选的offering,将该学生的课程时间放入一个临时的表里 while ($row = mysql_fetch_array($temp)) { //print_r($row); $offeringResult = getOfferingById($row['oid']); $offeringRow = mysql_fetch_array($offeringResult); // print_r($offeringRow); $timeTable = setOfferingTimeTable($offeringRow, $timeTable); } // print_r($timeTable); if (isOccupied($lecOid, $timeTable) == true) { // echo 1; if ($labOid != null) { if (isOccupied($labOid, $timeTable) == true) { // echo 1; saveStu_offering($sid, $cid, $lecOid, 2015); $cidL = $cid . "L"; saveStu_offering($sid, $cidL, $labOid, 2015); } else { $error[$count] = $cid . " lab offering time is occupied";
function isOccupied($oid, $timeTable) { //echo $oid; $result = getOfferingById($oid); $row = mysql_fetch_array($result); //print_r($row); $startArray = explode(":", $row['TimeStart']); $endArray = explode(":", $row['TimeEnd']); // echo $startArray[0]; // echo $endArray[0]; $startIndex = ((int) $startArray[0] - 7) * 12 + (int) $startArray[1] / 5; $endIndex = ((int) $endArray[0] - 7) * 12 + (int) $endArray[1] / 5; // echo $startIndex; // echo $endIndex; for ($i = $startIndex; $i <= $endIndex; $i++) { //echo $i." "; if ($row['Mon'] == "T") { if ($timeTable[0][$i] == "x") { return false; } } if ($row['Tue'] == "T") { if ($timeTable[1][$i] == "x") { return false; } } if ($row['Wed'] == "T") { if ($timeTable[2][$i] == "x") { return false; } } if ($row['Thu'] == "T") { if ($timeTable[3][$i] == "x") { return false; } } if ($row['Fri'] == "T") { if ($timeTable[4][$i] == "x") { return false; } } if ($row['Sat'] == "T") { if ($timeTable[5][$i] == "x") { return false; } } if ($row['Sun'] == "T") { if ($timeTable[6][$i] == "x") { return false; } } } return true; }
<table border="1" width="710" > <tr> <th height="20">Course ID</th> <th height="20">Course Title</th> <th height="20">Instructor Name</th> <th height="20">Class Time</th> <th height="20">Classroom</th> <th height="20">Taken in</th> <th height="20">Grade</th> </tr> <?php $result = getStu_offeringBySid($sid); while ($row = mysql_fetch_array($result)) { // echo $row['oid']; $innerResult = getOfferingById($row['oid']); // echo $innerResult; $innerRow = mysql_fetch_array($innerResult); echo "<tr>"; // echo "<td>"; // echo $innerRow['oid']; // echo "</td>"; echo "<td height='35'>"; echo $innerRow['cid'] . "<br/>" . strtoupper($innerRow['component']); echo "</td>"; echo "<td>"; echo ucwords($innerRow['courseTitle']); echo "</td>"; echo "<td>"; echo ucwords($innerRow['InstNameF']) . " " . ucwords($innerRow['InstNameL']); echo "</td>";