$query = "SELECT * FROM users"; $result = mysqli_query($conn, $query); while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo $row['name'] . " " . $row['email'] . "
"; }
$query = "SELECT * FROM orders WHERE id = 1"; $result = mysqli_query($conn, $query); $row = mysqli_fetch_array($result, MYSQLI_NUM); echo $row[0] . " " . $row[1] . " " . $row[2] . "In both examples, we are using the MySQL Improved Extension (mysqli) library to connect to the database and execute the query. The mysqli_fetch_array function is also part of the mysqli library.
";