I'm currently in the process of making a social network. I'm am displaying all registered users with the following code. Is there a better way of doing this?
<?php
$query = $db->query("SELECT * from members");
while($r = $query->fetch()) {
echo '<div class="col-sm-6 col-md-6 col-lg-3 membersGrid">';
echo '<div class="profileThumb">';
echo '<img width="130" height="130" src="'.$r['profile_pic'].'"/><br>';
echo $r['username'], '<br>';
echo $r['country'], '<br>';
echo '<a class="viewProfile" href="profile.php"><button>View Profile</button></a>';
echo '</div>';
echo '</div>';
}
?>
I'm trying to create a link to the individual profile pages for each users. Currently each link is within the above while loop, however, I'm a little uncertain of how to link to the relevant profile page. I'm guessing I have to append a variable to the URL. Any guidance would be greatly appreciated.
echo '<a class="viewProfile" href="profile.php"><button>View Profile</button></a>';