//connect to database $conn = mysqli_connect("localhost", "username", "password", "database"); //execute query $result = mysqli_query($conn, "SELECT * FROM users"); //retrieve data while ($row = mysqli_fetch_assoc($result)) { echo "Name: " . $row['name'] . "
"; echo "Email: " . $row['email'] . "
"; }
//connect to database $db = new PDO('mysql:host=localhost;dbname=mydatabase', 'username', 'password'); //execute query $stmt = $db->query("SELECT * FROM users"); //retrieve data while ($row = $stmt->fetch()) { echo "Name: " . $row['name'] . "In this example, we use getQuery() with a PDO database connection to retrieve all the data from the "users" table in a MySQL database. The package library for this function would depend on the specific PHP database library being used. For example, the mysqli_query() function is part of the mysqli extension, while the PDO query() function is part of the core PDO library.
"; echo "Email: " . $row['email'] . "
"; }