// Connection to the database server $conn = mysqli_connect("localhost", "username", "password", "dbname"); // Query for selecting data from the database $sql = "SELECT * FROM users WHERE age >= 18"; // Execute the query $result = mysqli_query($conn, $sql); // Fetch the data from the database while($row = mysqli_fetch_assoc($result)) { echo "Name: " . $row["name"]. " - Age: " . $row["age"]. "Package Library: MySQLi This code example uses MySQLi, which is a package library for accessing and working with MySQL databases. It provides improved functionality over the original MySQL package, including enhanced security features and support for prepared statements. The code connects to the database, executes a query to select data from a table, fetches the data, and then closes the connection to the server.
"; } // Close the connection to the database server mysqli_close($conn);