Current Directory:
/home/kridsana/webapp.cm.in.th/673190902/u67319090031/P001
Upload
Create File
File Name
Size
Actions
index.php
10144 bytes
Edit
|
Delete
|
Rename
|
Download
<!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; margin: 0; padding: 0; display: flex; justify-content: center; align-items: flex-start; height: 100vh; flex-direction: column; gap: 20px; overflow: hidden; /* ป้องกันการเลื่อนหน้าจอ */ background-color: #2f2f2f; /* สีพื้นหลังเข้ม */ color: white; } /* สร้างเอฟเฟกต์หิมะตก */ .snow { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: -1; /* ให้หิมะอยู่ด้านหลัง */ } .snowflake { position: absolute; top: -10px; background-color: white; border-radius: 50%; opacity: 0.8; animation: fall 5s linear infinite; } @keyframes fall { 0% { transform: translateX(0) translateY(0); opacity: 1; } 100% { transform: translateX(calc(100vw - 100px)) translateY(100vh); opacity: 0; } } .snowflake:nth-child(1) { width: 10px; height: 10px; animation-duration: 5s; left: 10%; } .snowflake:nth-child(2) { width: 15px; height: 15px; animation-duration: 6s; left: 20%; } .snowflake:nth-child(3) { width: 8px; height: 8px; animation-duration: 4s; left: 30%; } .snowflake:nth-child(4) { width: 12px; height: 12px; animation-duration: 7s; left: 40%; } .snowflake:nth-child(5) { width: 5px; height: 5px; animation-duration: 4s; left: 50%; } .snowflake:nth-child(6) { width: 14px; height: 14px; animation-duration: 8s; left: 60%; } /* กล่องคอนเทนต์ */ .main-container { display: flex; justify-content: center; align-items: flex-start; gap: 20px; width: 100%; z-index: 1; } .container { background-color: #444; border: 2px solid #ddd; padding: 20px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); width: 400px; text-align: center; background: linear-gradient(135deg, #222, #555); } h1 { color: #FFD700; font-size: 2.5rem; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); } label { font-size: 16px; color: #ddd; } input { width: 100%; padding: 12px; margin: 8px 0; border-radius: 8px; border: 1px solid #777; background-color: #333; color: #fff; box-sizing: border-box; font-size: 16px; } /* ปุ่มกด */ button { width: 100%; padding: 12px; background-color: #FF8C00; color: white; border: 2px solid #FF4500; border-radius: 8px; font-size: 18px; cursor: pointer; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); } button:hover { background-color: #FF6347; } button:active { background-color: #FF4500; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4); } h2 { color: #FFD700; } .result-box { border: 2px solid #FFD700; padding: 15px; border-radius: 8px; margin-top: 20px; background-color: #222; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2); } .grade-table { width: 30%; border-collapse: collapse; text-align: center; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); margin-top: 20px; font-size: 14px; background-color: #333; } th, td { padding: 12px; border: 1px solid #ddd; text-align: center; } th { background-color: #444; color: #FFD700; } tr:nth-child(even) { background-color: #555; } tr:hover { background-color: #666; } .grade-f { color: red; font-weight: bold; } .grade-table tbody tr:hover { background-color: #777; } @media (max-width: 768px) { .container { width: 90%; } .grade-table { width: 100%; } } </style> </head> <body> <!-- พื้นหลังหิมะตก --> <div class="snow"> <div class="snowflake"></div> <div class="snowflake"></div> <div class="snowflake"></div> <div class="snowflake"></div> <div class="snowflake"></div> <div class="snowflake"></div> </div> <div class="main-container"> <div class="container"> <h1>กรอกข้อมูลคะแนน</h1> <form method="POST" action=""> <label for="attitude">จิตพิสัย (คะแนนเต็ม 20): </label> <input type="number" name="attitude" id="attitude" required min="0" max="20"><br><br> <label for="test">แบบทดสอบ (คะแนนเต็ม 30): </label> <input type="number" name="test" id="test" required min="0" max="30"><br><br> <label for="homework">งาน (คะแนนเต็ม 20): </label> <input type="number" name="homework" id="homework" required min="0" max="20"><br><br> <label for="final_exam">สอบปลายภาค (คะแนนเต็ม 30): </label> <input type="number" name="final_exam" id="final_exam" required min="0" max="30"><br><br> <button type="submit">คำนวณเกรด</button> </form> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $attitude = isset($_POST['attitude']) ? $_POST['attitude'] : null; $test = isset($_POST['test']) ? $_POST['test'] : null; $homework = isset($_POST['homework']) ? $_POST['homework'] : null; $final_exam = isset($_POST['final_exam']) ? $_POST['final_exam'] : null; if ($attitude === null || $test === null || $homework === null || $final_exam === null) { $total_score = 0; $grade = 'F'; } else { $total_score = (($attitude / 20) * 20) + (($test / 30) * 30) + (($homework / 20) * 20) + (($final_exam / 30) * 30); if ($total_score >= 80) { $grade = 'A'; } elseif ($total_score >= 75) { $grade = 'B+'; } elseif ($total_score >= 70) { $grade = 'B'; } elseif ($total_score >= 65) { $grade = 'C+'; } elseif ($total_score >= 60) { $grade = 'C'; } elseif ($total_score >= 55) { $grade = 'D+'; } elseif ($total_score >= 50) { $grade = 'D'; } else { $grade = 'F'; } } echo "<div class='result-box'>"; echo "<h2>คะแนนรวม: $total_score</h2>"; if ($grade == 'F') { echo "<h2 class='grade-f'>เกรดของคุณ: $grade</h2>"; } else { echo "<h2>เกรดของคุณ: $grade</h2>"; } echo "</div>"; } ?> </div> <table class="grade-table"> <thead> <tr> <th>คะแนนรวม</th> <th>เกรด</th> </tr> </thead> <tbody> <tr> <td>80 - 100</td> <td>A</td> </tr> <tr> <td>75 - 79</td> <td>B+</td> </tr> <tr> <td>70 - 74</td> <td>B</td> </tr> <tr> <td>65 - 69</td> <td>C+</td> </tr> <tr> <td>60 - 64</td> <td>C</td> </tr> <tr> <td>55 - 59</td> <td>D+</td> </tr> <tr> <td>50 - 54</td> <td>D</td> </tr> <tr> <td>ต่ำกว่า 50</td> <td>F</td> </tr> </tbody> </table> </div> </body> </html>
Save Changes