在div中显示行[duplicate]

This question already has an answer here:

I had asked this question but didn't clarify what I wanted. I want the rows from table be displayed inside the div. I just want to break each row inside the div so while the div is the main container with background then the rows should align vertical, without creating another border. just the whole thing inside the div.

       .message{
        border:2px solid;
        background-color:white;
        float:left;
        }

php

 $user = $_SESSION['username'];
 $mydb = new mysqli('localhost', 'root', '', '');
 $stmt = $mydb->prepare("SELECT * FROM messages where from_user = ?  ");
 $stmt->bind_param('s', $user);
 $stmt->execute();


$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {

echo"<div class='message'>";


echo $row['to_user']."<br/>";

echo"</div>";

}
</div>

So div class="message" is the main container that you wnat all the content to be in rows inside of?

$result = $stmt->get_result();

echo"<div class='message'>";

while ($row = $result->fetch_assoc()) {

        echo $row['to_user']."<br/>";

}

echo"</div>";

Within the while loop; add the html to the print out, ie:

echo '<div class="message-line">'.$row['to_user'].'</div>';

This will make each row from the table a new line within the message container. It will also allow you to style it to your hearts content later on.