Skip to content
PHP Logo

How can PHP be used to format and display database outputs, such as profile pictures, in a specific layout?

To format and display database outputs, such as profile pictures, in a specific layout, you can use PHP to retrieve the data from the database and then use HTML and CSS to structure and style the output. You can use PHP to loop through the database results and display each profile picture in a designated container with the desired layout.

php
<?php
// Assuming $profilePictures is an array containing the file paths of profile pictures from the database

echo '<div class="profile-pictures">';
foreach ($profilePictures as $picture) {
    echo '<div class="profile-picture">';
    echo '<img src="' . $picture . '" alt="Profile Picture">';
    echo '</div>';
}
echo '</div>';
?>