www.webdeveloper.com
Results 1 to 2 of 2

Thread: Insert "Line Break" in the SQL dataBase

  1. #1
    Join Date
    Feb 2009
    Posts
    13

    Insert "Line Break" in the SQL dataBase

    Hi,

    I have the following content I want to insert into SQL database with the line break after each sentence, how should I do that?

    INSERT INTO tblTemplateEmail (EmailID, EmailBody)
    Values( 63,'Dear Manager First Name,,Welcome ! Your first step is to set up a Manager account in our system, as follows: Starting at website . Click on Manager login. Click on Setup an Account. Fill out all your information . MessageID:63.0.0')


    thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,334
    You should probably not have to do anything special other than using the normal newline character. When you retrieve it from the DB and want to display the data, then you might want to replace the newlines with HTML <br /> tags, which may be most easily done within your application code rather than the SQL. For instance, in PHP you can use the built-in nl2br() function:
    PHP Code:
    echo "<p>" nl2br($text_from_database) . "</p>\n"
    You might ask, "Why not just insert the <br /> tags into the database field?" If you do that, then you have output-specific data in there that you might not want in future uses of that data, which might mess up search functions you need to run on the data, etc.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles