How can the PHP code be modified to display only the files relevant to the logged-in user?

To display only the files relevant to the logged-in user, you can modify the PHP code to retrieve the files associated with the user's ID from the database. This can be achieved by querying the database for files that have a user_id matching the ID of the logged-in user.

// Assuming $loggedInUserId contains the ID of the logged-in user

// Query the database for files associated with the logged-in user
$query = "SELECT * FROM files WHERE user_id = $loggedInUserId";
$result = mysqli_query($connection, $query);

// Display the relevant files
while($row = mysqli_fetch_assoc($result)) {
    echo $row['file_name'] . "<br>";
}