File manager - Edit - /home/kridsana/webapp.cm.in.th/663012801/u66301280022/p002/index.php
Back
<!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: "Times New Roman", Times, serif; margin: 0; padding: 20px; background-color: #4A415C; } .form-container { background-color: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); max-width: 700px; margin: auto; } h2 { text-align: center; } table { width: 100%; margin-bottom: 20px; } table td { padding: 10px; text-align: left; } table input { width: 100%; padding: 8px; font-size: 16px; border: 1px solid #ccc; background-color: #F2C2CF; border-radius: 4px; } .form-group { text-align: center; } .form-group input[type="submit"] { background-color: #2E99DB; color: white; border: none; cursor: pointer; font-size: 18px; } .form-group input[type="submit"]:hover { background-color: #45a049; } .result { margin-top: 20px; padding: 15px; background-color: #eef2f3; 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 = 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; $totalScore = $spirit + $test + $assignment + $finalExam; $grade = ''; 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 class="result">'; echo '<h3>ผลการคำนวณเกรด</h3>'; echo '<p>จิตพิสัย: ' . $spirit . ' คะแนน</p>'; echo '<p>สอบเก็บคะแนน: ' . $test . ' คะแนน</p>'; echo '<p>งาน: ' . $assignment . ' คะแนน</p>'; echo '<p>สอบปลายภาค: ' . $finalExam . ' คะแนน</p>'; echo '<hr>'; echo '<p>คะแนนรวม: ' . $totalScore . ' คะแนน</p>'; echo '<p>เกรดที่ได้รับ: ' . $grade . '</p>'; echo '</div>'; } ?> </div> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.8 |
proxy
|
phpinfo
|
Settings