File manager - Edit - /home/kridsana/webapp.cm.in.th/663012801/u66301280023/P001/index.php
Back
<!DOCTYPE html> <html> <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; margin: 0; padding: 20px; background-color: #2A3663; } .form-container { background-color: #FAF6E3; padding: 50px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); max-width: 500px; margin: auto; } h2 { text-align: center; } table { width: 90%; margin-bottom: 20px; } table td { padding: 10px; text-align: left; } table input { width: 100%; padding: 8px; font-size: 16px; border: 1px solid #ccc; border-radius: 4px; } .form-group { text-align: center; } .form-group input[type="submit"] { background-color: #B59F78; color: black; border: none; cursor: pointer; font-size: 18px; } .form-group input[type="submit"]:hover { background-color: #D8DBBD; } .result { margin-top: 20px; padding: 15px; background-color: #D8DBBD; border: 1px solid #ccc; border-radius: 8px; text-align: center; font-size: 18px; } .result h3 { margin: 0; } .result p { margin: 10px 0; } </style> </head> <body> <div class="form-container"> <h2>ฟอร์มกรอกคะแนนและคำนวณเกรด</h2> <form method="POST" action=""> <table> <tr> <td><label for="spirit">จิตพิสัย (20 คะแนน)</label></td> <td><input type="number" id="spirit" name="spirit" min="0" max="20" required> คะแนน</td> </tr> <tr> <td><label for="test">แบบทดสอบ (30 คะแนน)</label></td> <td><input type="number" id="test" name="test" min="0" max="30" required> คะแนน</td> </tr> <tr> <td><label for="assignment">งาน (20 คะแนน)</label></td> <td><input type="number" id="assignment" name="assignment" min="0" max="20" required> คะแนน</td> </tr> <tr> <td><label for="final_exam">สอบปลายภาค (30 คะแนน)</label></td> <td><input type="number" id="final_exam" name="final_exam" min="0" max="30" required> คะแนน</td> </tr> </table> <div class="form-group"> <input type="submit" value="คำนวณเกรด"> </div> </form> <!-- แสดงผลคะแนนรวมและเกรด --> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $spirit = intval($_POST['spirit']); $test = intval($_POST['test']); $assignment = intval($_POST['assignment']); $final_exam = intval($_POST['final_exam']); // คำนวณคะแนนรวม $totalScore = $spirit + $test + $assignment + $final_exam; // กำหนดเกรดตามคะแนนรวม 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 '<h2>ผลการคำนวณเกรด</h2>'; echo '<p id="totalScore">คะแนนรวม: ' . $totalScore . ' คะแนน</p>'; echo '<p id="grade">เกรดที่ได้รับ: ' . $grade . '</p>'; echo '<hr>'; echo '</div>'; } ?> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 1.1 |
proxy
|
phpinfo
|
Settings