====== PHP example for MySQL database connection ====== 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]."
\n"; } // Free result set $result->close(); // close connection $mysqli->close(); ?>