How can PHP beginners effectively format and display data retrieved from a database in a user-friendly way?

To effectively format and display data retrieved from a database in a user-friendly way, PHP beginners can use HTML and CSS to structure and style the data. They can also utilize PHP functions such as `mysqli_fetch_assoc()` to fetch data from the database and loop through the results to display them in a desired format.

<?php
// Connect to the database
$conn = mysqli_connect("localhost", "username", "password", "database");

// Retrieve data from the database
$query = "SELECT * FROM table";
$result = mysqli_query($conn, $query);

// Display data in a user-friendly way
echo "<table>";
while ($row = mysqli_fetch_assoc($result)) {
    echo "<tr>";
    echo "<td>".$row['column1']."</td>";
    echo "<td>".$row['column2']."</td>";
    // Add more columns as needed
    echo "</tr>";
}
echo "</table>";

// Close the database connection
mysqli_close($conn);
?>