我正在尝试对数据库中的结果进行样式设置,但是当我回显时<div>
,它会在每个结果之后创建新行。如何强制 div 不创建新行?
.message {
border:2px solid;
background-color:white;
}
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'];
echo"</div>";
}