everyuser should have a unique id store in the db once they sign-up. that unique id will be their profile id. so for example, if you would like to view a user, i would recommend you to create a page called profile.php and use the get function to get the id which is given. if there is no id given, show the user's profile instead.
<?php
session_start();
if(empty($_GET['id']) || !empty($_SESSION['username'])) {
// mysql query for user's id and etc
}
else {
//mysql query for $id and etc
$id = $_GET['id'];
}
?>