Code segment: when inserting text data into mysql, the solution with format

Source: Internet
Author: User
Code segment: when inserting text data into mysql, the front-end with a format does not need an editor, and only uses the & lt; textarea & gt; format to insert a text with a format to MYSQL. In the future, formatted text will be directly displayed at the front end. first, I want to explain that the concept of segmentation does not exist in textarea unless you use the UBB-class text editor; & nbsp; second, find the code section in t: when inserting text data into mysql, the format is
Front-end editor is not required, only Insert formatted text to MYSQL.

In the future, formatted text will be displayed on the front-end.

------ Solution --------------------
First, I want to explain that the concept of segmentation does not exist in textarea;
Unless you use the UBB text editor;

Second, in textarea, only line breaks, other bold, font, size, color, labels, and so on will not have any effect;
Therefore, in textarea, only the line feed mode can be retained;

Php processes line breaks;
Stored in the database:
$ Content = str_replace ("
", Chr (10), $ content); // chr (10) line break ascii code

Input is edited in textarea;
$ Content = str_replace ("\ n ","
", $ Content );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.