mysql 数据显示中的问题
Issue in mysql data display
我正在以某种方式将数据存储到数据库中。例如 - 使用 enter , spaces。并且它以相同的方式成功存储但是当我输出那些存储的数据时,它只显示在一行中。它不考虑我所做的任何白色 space 或输入。我想以同样的方式显示数据。
CRLF 在HTML 中不作为换行符。
示例:
<pre>
your data field bound variable name here
that has
line feed and carriage return
as part of it's content
</pre>
在打印 MySQL 数据时使用 PHP 中的 nl2br()
函数。
echo nl2br($row["column"]);
或者,如果您需要将它们显示得与存储方式完全一样,则需要使用 <pre>
标签,或者您可以将显示对象的 CSS 设置为:
white-space: pre-wrap;
考虑这样的文本:
I have a big house!
And there's a line before this line!
Also I have left a huge space!
上面的全部文字将显示在 <div>
中,如下所示:
I have a big house!
And there's a line before this line!
Also I have left a huge space!
div {white-space: pre-wrap; font-family: 'Segoe UI', Tahoma, sans-serif;}
<div>
I have a big house!
And there's a line before this line!
Also I have left a huge space!
</div>
我正在以某种方式将数据存储到数据库中。例如 - 使用 enter , spaces。并且它以相同的方式成功存储但是当我输出那些存储的数据时,它只显示在一行中。它不考虑我所做的任何白色 space 或输入。我想以同样的方式显示数据。
CRLF 在HTML 中不作为换行符。
示例:
<pre>
your data field bound variable name here
that has
line feed and carriage return
as part of it's content
</pre>
在打印 MySQL 数据时使用 PHP 中的 nl2br()
函数。
echo nl2br($row["column"]);
或者,如果您需要将它们显示得与存储方式完全一样,则需要使用 <pre>
标签,或者您可以将显示对象的 CSS 设置为:
white-space: pre-wrap;
考虑这样的文本:
I have a big house!
And there's a line before this line!
Also I have left a huge space!
上面的全部文字将显示在 <div>
中,如下所示:
I have a big house!
And there's a line before this line! Also I have left a huge space!
div {white-space: pre-wrap; font-family: 'Segoe UI', Tahoma, sans-serif;}
<div>
I have a big house!
And there's a line before this line!
Also I have left a huge space!
</div>