?> </td> <td><?php echo $sub12_m; ?> </td> <td><?php echo $sub13_m; ?> </td> <td><?php echo $sub12tm = ($sub12_m + $sub13_m) / 2; ?> </td> <td><?php echo check_grade($sub12tm); ?> </td> </tr> <?php $val = 1; $pass = '******'; if ($pass <= $sub1tm) { if ($pass <= $sub3tm) { if ($pass <= $sub5tm) { if ($pass <= $sub6tm) { if ($pass <= $sub8tm) { if ($pass <= $sub10tm) { if ($pass <= $sub12tm) { $gr_sub12 = check_grade_point($sub12tm);
function edit_student() { $student_id = addslashes($_REQUEST["student_id"]); $name = addslashes($_REQUEST["name"]); $address = addslashes($_REQUEST["address"]); $phone = addslashes(check_phone($_REQUEST["phone"])); $email = addslashes(check_email($_REQUEST["email"])); $grade = addslashes(check_grade($_REQUEST["grade"])); $avail = get_avail(); if (!count_times($avail)) { show_error("You haven't selected any periods that you are available for tutoring. Please go back and fill in at least one period."); } $username = addslashes($_REQUEST["username"]); $notes = addslashes($_REQUEST["notes"]); $signed_contract = $_REQUEST["signed_contract"] ? 1 : 0; if ($_REQUEST["password"]) { $password = addslashes(md5(check_password($_REQUEST["password"], $_REQUEST["password2"]))); } $username_id = username_exists($username); if ($username_id != $student_id && $username_id != 0) { show_error("That username already exists"); } $DB = new DB(); $query = "UPDATE student SET\n"; if ($password) { $query .= "password='******',"; } $query .= "name='{$name}',\n address='{$address}',\n phone='{$phone}',\n email='{$email}',\n grade='{$grade}',\n username='******',\n notes='{$notes}',\n signed_contract={$signed_contract}\n WHERE id={$student_id}"; $DB->query($query); update_availability($avail, $student_id); }
?> </strong></td> <td style="font-size:12px" > <?php echo $name; ?> </td> <td style="font-size:12px" > <?php echo $department1; ?> </td> <td align="center" width=" " style="font-size:14px" ><strong><?php echo $dbsub_m; ?> </strong></td> <td align="center" width=" " style="font-size:14px" ><strong><?php echo check_grade($dbsub_m); ?> <strong></td> <?php } } } echo mysql_error(); ?> <?php mysql_close(); ?> </tr>
echo "化學成績輸入要介於0~100喔\n"; } } else { echo "你沒有輸入化學成績喔\n"; return false; } if ($chinese <= 100 && $chinese >= 0 && $english <= 100 && $english >= 0 && $mathematics <= 100 && $mathematics >= 0 && $physics <= 100 && $physics >= 0 && $chemical <= 100 && $chemical >= 0) { return true; } else { return false; } } $sum = $chinese + $english + $mathematics + $physics + $chemical; $average = $sum / 5; //=================================呼叫函數================================== if (check_name($name) && check_ID($ID) && check_email($email) && check_grade($chinese, $english, $mathematics, $physics, $chemical) == 1) { //=================================寫入到grade.txt================================== $filename = 'grade.txt'; $content = $name . " " . $ID . " " . $email . " " . $chinese . " " . $english . " " . $mathematics . " " . $physics . " " . $chemical . " " . $sum . " " . $average; if (is_writable($filename)) { $fopen = fopen($filename, 'a'); if ($fopen == false) { echo '無法開啟檔案: ' . $filename; exit; } $fwrite = fwrite($fopen, "{$content}\r\n"); if ($fwrite == false) { echo '檔案寫入失敗: ' . $filename; exit; } echo '寫入檔案成功 開啟瞧瞧吧: <a href="' . $filename . '">' . $filename . '</a><br>';