<?php
$host="localhost";
$user="root";
$pass="rooter";
$db="TestDB";
// Connect to the MySQL database
$conn = new mysqli($host, $user, $pass, $db);
// Check the connection
if ($conn->connect_error) {
    die("Connection failed: ".$conn->connect_error);
}

// Query the table
$sql = "SELECT * FROM Person";
$result = $conn->query($sql);
$Grade = 'U';
// Display the results
if ($result->num_rows > 0) {
    echo "<h2>Person Table</h2><table border='1'><tr><th>ID</th><th>Name</th><th>Grade</th></tr>";
    while ($row = $result->fetch_assoc()) {
        if ($row["Grade"]>=80)
        {
            $Grade = 'A';
        }elseif ($row["Grade"]>=70) {
            $Grade = 'B';
        }elseif ($row["Grade"]>=60) {
            $Grade = 'C';
        }elseif ($row["Grade"]>=50) {
            $Grade = 'D';
        }elseif ($row["Grade"]>=40) {
            $Grade = 'E';
        }else {
            $Grade = 'F';
        }
        
        echo "<tr><td>".$row["ID"]."</td><td>".$row["Name"]."</td><td>".$Grade."</td></tr>";
    
    }
    echo "</table>";
} else {
    echo "No records found.";
}

$conn->close();
?>