Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8108201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:01:48+00:00 2026-06-06T01:01:48+00:00

I have multiple lines of text entered into a single MySQL longtext cell that

  • 0

I have multiple lines of text entered into a single MySQL longtext cell that I would like to display in HTML. However, I cannot figure out how to keep the line break when the string is displayed in HTML.

For example, let’s say I have this text in the column “content”:

+-----------+
|  content  |
+-----------+
| Line 1.   |
|           |
| Line 2.   |
+-----------+

I want this to display:

Line 1.

Line 2.

However, I am getting this result with my PHP loop:

Line1.Line2.

I used the loop below to echo the text from my database. (I know I don’t need a loop, but in the actual project I am displaying multiple rows of data).

$query = mysql_query("SELECT * FROM table ORDER BY timestamp DESC");
while($row = mysql_fetch_array($query)) {
    echo $row['title'];
}

In sum: How can I maintain line breaks when displaying a MySQL string in HTML? Is there any way to add <br> at the line breaks?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:01:51+00:00Added an answer on June 6, 2026 at 1:01 am

    Try using php function nl2br (docs)

    $content = "Line 1.\nLine 2.";
    echo nl2br($content);
    // output Line 1.<br>\nLine 2.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textarea with text entered on multiple lines. I submit that using
Is there a way to have multiple lines of text in UILabel like in
I have multiple lines of texts in a text file that look similar to
I have an HTML table of data where each cell can have multiple lines
If I have a textarea on an HTML page with multiple lines of text
I have a serial connection that gives me multiple lines of text continuously. I
I have a text files that contains multiple lines, each line has the following
I have a long label that spans multiple lines and I can not get
A UILabel's text is drawn in a CGRect(x,y,size,width). The label can have multiple lines
I have a RoundedRectView with a UILabel that holds lines of text of varying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.