SQL to HTML Table, new

I can’t figure out why my code isn’t working? When i run it the page is blank!

This is a Harry Potter Database. I am trying to put the data within my SQL Database in a HTML Table. Sounds easy but I can’t figure out why my code is not working!

<!DOCTYPE html>
    <title> Harry Potter Database </table>
        <th> ID </th>
        <th> Name </th>
        <th> Age </th>
        <th> Website </th>
ini_set('display_errors', 1); 
ini_set('display_startup_errors', 1); error_reporting(E_ALL); 
$conn = mysqli_connect("localhost", "root", "", "survey");
$sql = "SELECT * FROM result";
$res = $conn->query($sql);

if($res->num_rows > 0)
    while($row = $res->fetch_assoc())
        echo "<tr>
        <td>". $row["ID"] . "</td>
        <td>". $row["Name"] . "</td>
        <td>". $row["Age"] . "</td>
        <td>". $row["Website"] . "</td>
    echo "No RESULTS";


result is the name data within my database called survey

Undefined array key “ID” in C:xampphtdocsws5sqlquery.php on
line 26

This is the error in the source

Structure of Table



Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

On Windows (where it looks like you are), MySQL stores all table and column names in lowercase by default (see the docs for “Identifier Case Sensitivity” and lower_case_table_names).

That means that instead of "ID", you should be using "id", instead of "Name" it should be "name", etc.

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x