Gestionnaire de fichiers - Editer - /home/kridsana/webapp.cm.in.th/663012801/u66301280014/P002/index.php
Arrière
<!DOCTYPE html> <html lang="th"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>คำนวณเกรด</title> <style> body { font-family: Arial, sans-serif; background-color: #E4F3D8; padding: 20px; } h2 { text-align: center; color: #333; } .form-container { background-color: #ffffff; padding: 20px; border: 1px solid #ccc; width: 300px; margin: 0 auto; } .form-container input { width: 100%; padding: 8px; margin: 10px 0; border: 1px solid #4CAF50; } .form-container input[type="submit"] { background-color: #007BFF; color: white; cursor: pointer; border: 1px solid #0056b3; } .form-container input[type="submit"]:hover { background-color: #0056b3; } .result { margin-top: 20px; padding: 10px; background-color: #e0f7fa; text-align: center; } </style> </head> <body> <div class="form-container"> <h2>คำนวณเกรด</h2> <form method="POST"> <label for="spirit">จิตพิสัย (20 คะแนน)</label> <input type="number" id="spirit" name="spirit" max="20" required> <label for="test">แบบทดสอบ (30 คะแนน)</label> <input type="number" id="test" name="test" max="30" required> <label for="assignment">งาน (20 คะแนน)</label> <input type="number" id="assignment" name="assignment" max="20" required> <label for="final_exam">สอบปลายภาค (30 คะแนน)</label> <input type="number" id="final_exam" name="final_exam" max="30" required> <input type="submit" value="คำนวณเกรด"> </form> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { // รับค่าจากฟอมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมม $spirit = isset($_POST['spirit']) ? (int)$_POST['spirit'] : 0; $test = isset($_POST['test']) ? (int)$_POST['test'] : 0; $assignment = isset($_POST['assignment']) ? (int)$_POST['assignment'] : 0; $finalExam = isset($_POST['final_exam']) ? (int)$_POST['final_exam'] : 0; // ตรวจสอบคะแนนว่าเกินขีดจำกัดหรือไม่ if ($spirit > 20) $spirit = 20; if ($test > 30) $test = 30; if ($assignment > 20) $assignment = 20; if ($finalExam > 30) $finalExam = 30; // คำนวณคะแนนรวมมมมมมมมมมมมมมมมมมมมมมมมมมมมมมม $totalScore = $spirit + $test + $assignment + $finalExam; // คำนวณเกรดดดดดดดดดดดดดดดดดดดดดดดดดดดดดดดดดดดดดด if ($totalScore >= 80) { $grade = 'A'; } elseif ($totalScore >= 75) { $grade = 'B+'; } elseif ($totalScore >= 70) { $grade = 'B'; } elseif ($totalScore >= 65) { $grade = 'C+'; } elseif ($totalScore >= 60) { $grade = 'C'; } elseif ($totalScore >= 55) { $grade = 'D+'; } elseif ($totalScore >= 50) { $grade = 'D'; } else { $grade = 'F'; } // แสดงผลลลลลลลลลลลลลลลลลลลลลลลล echo '<div id="result" class="result">'; echo '<h3>ผลการคำนวณเกรด</h3>'; echo '<p>คะแนนรวม: ' . $totalScore . '</p>'; echo '<p>เกรด: ' . $grade . '</p>'; echo '</div>'; } ?> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Génération de la page: 0.31 |
proxy
|
phpinfo
|
Réglages