How can one properly access and display the elements of an array fetched from a MySQL query in PHP?

When fetching an array from a MySQL query in PHP, you can access and display its elements by using a foreach loop. This loop allows you to iterate over each element in the array and display its values accordingly. By using this method, you can easily access and display the data retrieved from the MySQL query.

// Assuming $result is the array fetched from the MySQL query
foreach ($result as $row) {
    echo $row['column_name']; // Replace 'column_name' with the actual column name in your database
}