私人收件箱中发件人和收件人的不同背景颜色

I made a simple static private message script in php and i want different color background for sender's and receiver's message

$sql="SELECT  message,timestamp from pm WHERE (from_user='".$_SESSION["username"]."' OR from_user='$touser') AND (to_user='$touser' OR to_user='".$_SESSION["username"]."') ORDER BY timestamp";
                        $ex=$conn->prepare($sql);
                        $ex->execute();
                        while($result=$ex->fetch(PDO::FETCH_ASSOC))
                            {
                                echo "<div class='message-view'>";

                                echo "<p class='subject'>".$result["message"]."</p>";

                                echo "</div>";
                            }

the pm table has the following attributes (id,to_user,from_user,subject,message,timestamp)

change:

$sql="SELECT  message,timestamp from pm WHERE (from_user='".$_SESSION["username"]."' OR from_user='$touser') AND (to_user='$touser' OR to_user='".$_SESSION["username"]."') ORDER BY timestamp";

to

$sql="SELECT  message,timestamp,from_user  from pm WHERE (from_user='".$_SESSION["username"]."' OR from_user='$touser') AND (to_user='$touser' OR to_user='".$_SESSION["username"]."') ORDER BY timestamp";

and then check during while specific class depending on who was a sender:

if ($result['from_user'] == $_SESSION["username"])
    echo '<div class="message-view-sender" style="background-color: yellow;">';
else
    echo "<div class='message-view'>";