gpt4 book ai didi

php - Mysql查询格式化问题

转载 作者:搜寻专家 更新时间:2023-10-30 22:15:01 24 4
gpt4 key购买 nike

我正在构建一个私有(private)消息系统,我的数据库有多行。在数据库中:

I love that song do you?

-Joe

但我的查询最终显示如下

I love that song do you? -Joe

这是我的问题

<?php
include 'core/init.php';
protect_page();
include 'includes/overall/header.php';
$username = $user_data['username'];
?>
<?php
$result = mysql_query("SELECT * FROM messages Where sentto1='$username'");
echo '<h2>Messages: </h2><br>';
while($row = mysql_fetch_array($result)){


echo '<b>From: ';
echo $row['from1'];
echo '</b><br><br>';

echo 'Subject: ';
echo $row['subject1'];

echo '<br><br>';
echo 'Message: ';
echo $row['message1'];
echo "<br />";
echo "<br />";
}

?>
<?php include 'includes/overall/footer.php'; ?>

提前致谢。

最佳答案

使用nl2br() , 这将用 HTML <br> 替换所有换行符标签。

  echo nl2br($row['message1'], false);

关于php - Mysql查询格式化问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14915960/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com