如何循环不同的数据?

Let's Say I have Data... ID... 1, 2, 3, 4, 5, 6
FirstName... Donald, Tabatha, Jeremy, Samuel, Donald, Tabatha
LastName... Faulknor, Kolasa, Jones, Jackson, Faulknor, Kolasa

In this example, I would want to display Donald Faulknor, Tabatha Kolasa, Jeremy Jones, Samuel Jackson

I can either display all data (repeating the duplicate entries) or, if I use

SELECT DISTINCT
then I will only display the first instance, which in this case would be Donald Faulknor. Here's my code...
$sql55 = "SELECT * FROM messages WHERE lowerID = :lowerIDb || higherID = :higherIDb";
    $stmt55 = $pdo->prepare($sql55);
    $stmt55->bindValue(':lowerIDb',$user_id);
    $stmt55->bindValue(':higherIDb',$user_id);
    $stmt55->execute();
    while($row55 = $stmt55->fetch(PDO::FETCH_ASSOC)) {
        $lowerID55 = $row55['lowerID'];
        $higherID55 = $row55['higherID'];
        if($lowerID55 == $user_id) { $user_id55 = $higherID55; } elseif($higherID55 == $user_id) { $user_id55 = $lowerID55; }
        $sql56 = "SELECT DISTINCT user_id FROM users WHERE user_id = :user_id55";
        $stmt56 = $pdo->prepare($sql56);
        $stmt56->bindValue(':user_id55',$user_id55);
        $stmt56->execute();
        while($row56 = $stmt56->fetch(PDO::FETCH_ASSOC)) {
            $id56 = $row56['user_id'];
            $sql58 = "SELECT * FROM users WHERE user_id = :user_id58";
            $stmt58 = $pdo->prepare($sql58);
            $stmt58->bindValue(':user_id58',$id56);
            $stmt58->execute();
            while($row58 = $stmt58->fetch(PDO::FETCH_ASSOC)) {
            $firstname56 = $row58['firstname'];
            $lastname56 = $row58['lastname'];
            $profilePhoto56 = $row58['profilePhoto'];
            $sql57 = "SELECT * from photos WHERE id = :profilePhotoa";
            $stmt57 = $pdo->prepare($sql57);
            $stmt57->bindValue(':profilePhotoa',$profilePhoto56);
            $stmt57->execute();
            while($row57 = $stmt57->fetch(PDO::FETCH_ASSOC)) {
                $profilePhotoPath57 = $row57['path'];
            echo '';
            echo ' '.$firstname56.' '.$lastname56.'';
        }
    }
    }}

To better understand the above code... I have messages to and from users, of course, there will be many to and from the same users. I'm trying to get their name (the recipient) to show once in a side bar (indicating messages from/to that person. Let's say for example, I have 20 messages to and from one person. I can either get the name to repeat twenty times (not using DISTINCT) or I can only get one person's name to show (using DISTINCT). So if there's 8 people to send this user an email, only one name will show.

Much help is greatly appreciated. For questions or more elaboration, please feel free to ask questions. Thank You! :)