PHP example for MySQL database connection

<head>
</head>
<body>

<?php

    // Make a connection to the database
    // the values here MUST BE CHANGED to match the database and credentials you wish to use
    $mysqli = new mysqli("localhost", "user", "password", "database");
    if ($mysqli->connect_errno)
    {
      echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
    }

    // Define the SQL query, replace table name and column names as necessary
    $sql = "SELECT * FROM table WHERE id > 1";

    // Execute the query
    $result = $mysqli->query($sql);

    // If the $result variable is not defined, there was an error in the query
    if !($result)
    {
      echo "Query execution failed: (" . $mysqli->errno . ") " . $mysqli->error;
    }

    // Iterate through each row of the result
    while($row = $result->fetch_array())
    {
      // Write HTML to the page, replace this with whatever you wish to do with the data
      echo $row[0]."<br/>\n";
    }

    // Free result set
    $result->close();

    // close connection
    $mysqli->close();
?>

</body>
</html>