gpt4 book ai didi

php - 显示带空格或中断的提取数据 - PHP

转载 作者:太空宇宙 更新时间:2023-11-03 21:19:54 24 4
gpt4 key购买 nike

我想显示带有一些空格或换行的数据。有人可以帮我解决这个问题吗?我使用 textarea 添加和编辑新闻内容。我的新闻内容的数据类型是 text

我的内容想这样显示。 enter image description here

这是我的作品。如您所见,那里没有中断 enter image description here

这是获取数据的代码。

<?php
include_once('connection.php');
$newsid = $_GET['newsid'];

$sql ="SELECT * FROM news WHERE news_id = '$newsid'";
$result = mysqli_query($con, $sql);

while($row = mysqli_fetch_array($result)){
$title = $row['news_title'];
$date = $row['news_date'];
$content = $row['news_content'];
$newsimage = $row['news_image'];
}
?>

<img src="<?php echo $newsimage; ?>" alt="court" style="width:100%; height:430px; ">
<div class="content">
<div class="container">
<div class="row">
<div class="fix midbar">
<div class="viewnews">
<h3><?php echo $title; ?> </h3>
<p>Date posted: <?php echo $date; ?></p>
<p><?php echo $content; ?></p>
</div>
</div>

</div>
</div>
</div>

最佳答案

您可以使用nl2br

nl2br — 在字符串中的所有换行符之前插入 HTML 换行符

描述

string nl2br ( string $string [, bool $is_xhtml = true ] )

返回带 <br /> or <br> 的字符串在所有换行符之前插入 (\r\n, \n\r, \n and \r).

关于php - 显示带空格或中断的提取数据 - PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38394951/

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