如何在mysql记录中包含分隔线? [英] How can I include break lines in mysql records?

查看:195
本文介绍了如何在mysql记录中包含分隔线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 您好,

我叫约翰,今年22岁,正在寻找美好的时光。

我的电话号码是:
555-NOT-REAL

此致
约翰D.

我想让分隔线留在那里,但是当我把这个值拉回来的时候,它出现如下。

 您好,我叫约翰,今年22岁,正在寻找美好时光。我的电话号码是:555-NOT-REAL此致John D. 

是否有一种特殊的保持放入的文本格式的字段?我很确定它已经在那里了,因为当我看数据库中的字段时,确实出现了细线。也许这是我检索它的方式?

我不喜欢编写一些东西来放入HTML标签,哈哈。如果你在浏览器中显示文本,你可以用来放置HTML标签。

浏览器不会自动为你换行。这是最常用的 nl2br 功能:

  nl2br($ message); 

然而,您也可以围绕 < pre> 标记,但我不建议这样做:

 < pre> $ message< / pre> 


When someone types in the following to be put into a database:

Hello,

My name is John and I am 22, and looking for a good time.

My Phone Number is:
555-NOT-REAL

Sincerely,
John D.

I want the break lines to stay there, but it seems that when I pull the value back out it comes out as follows.

Hello, My name is John and I am 22, and looking for a good time. My Phone Number is: 555-NOT-REAL Sincerely,John D.

Is there a special kind of field that keeps the format of the text that is put in? I am pretty sure that it is already in there because when I look at the field in the database the breaklines do appear. Maybe it is the way I am retrieving it?

I prefer not to have to code something to put in HTML tags, haha. Thanks!

解决方案

If you are displaying the text in the browser, you have to put HTML tags in. Browsers do not automatically put linebreaks for you. This is most commonly done with the nl2br function:

nl2br($message);

However, you could also wrap your text around the <pre> tag, but I don't recommend it:

<pre>$message</pre>

这篇关于如何在mysql记录中包含分隔线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆