My solution is simple.
Let's say, from what you said, you store logged in user ID on $_SESSION and so, you get and use that user ID when you visit the page to fetch the user info from the database, then display it.
Now, here's what I think. Just have a simple IF statement.
$uid = (isset($_GET['uid'])) ? $_GET['uid'] : $_SESSION['uid'];
$query = "SELECT * FROM users WHERE id = $uid";
It gets the ID from the URL if it is set, if not, use the id from the session.
// this is an example of a URL with uid = 12.
http://yourwebsite.com/profile.php?uid=12
So what this does, even if a user is logged in, if s/he visit the page with a uid = n
, s/he will see someone else's profile.
And so, you have to append/have uid = n
on every link of your user list.
NOTE: That just a quick and simple example, that code isn't good as is. (i.e. security and validation)