Results 1 to 5 of 5

Thread: Problem with line in a textarea

  1. #1
    Join Date
    Nov 2008
    Posts
    996

    Problem with line in a textarea

    I want to insert each line of the user <br/> when I get data in my table.

    After researching the net, I came across the nl2br function to allow this.

    The insertion of "<br/>" is made correctly but when I update my textarea, I find myself with several "<br/>" stuck in a row.

    I tried nl2br (htmlentities ($var)) but nothing fits in my desk.

    Inserting data into my table:

    PHP Code:
    field_form1 addslashes($_POST['field1']); 
    field_form2 addslashes($_POST['field2']); 
    field_form3 addslashes($_POST['field3']); 
    field_form4 addslashes($_POST['field4']); 
    field_form1 explode("\n",$field_form1); 
    field_form2 explode("\n",$field_form2); 
    field_form3 explode("\n",$field_form3); 
    field_form4 explode("\n",$field_form4); 
    .... 
    Displays data in the textarea :

    PHP Code:
    echo '<textarea name="field'.$i.'" rows="10">'
    $sql_textarea mysql_query ("select id_description, text $i"."_description from description where theme_description = '$theme' and nb_parts_description = '$nb"); 
    while (
    $data mysql_fetch_array ($sql_textarea)) {
    $content nl2br ($data["text $i"."_description"]); 
    echo 
    htmlentities ($content); 
    }
    echo 
    "</textarea>"

  2. #2
    Join Date
    May 2008
    Posts
    945

    Re: Problem with line in a textarea

    The n12br should not be used with a textarea because textarea goes to the new line with the \n.

  3. #3
    Join Date
    Feb 2008
    Posts
    194

    Re: Problem with line in a textarea

    Not that it is especially if it displays <br/> in a textarea, its sure it will not line breaks. nl2br returns a string where line breaks are replaced by <br/> tags that will not be interpreted in the textarea.

  4. #4
    Join Date
    Nov 2008
    Posts
    996

    Re: Problem with line in a textarea

    What do you recommend?

  5. #5
    Join Date
    May 2008
    Posts
    945

    Re: Problem with line in a textarea

    Simply in the textarea do not use the nl2br, you leave as it is (in your table and let the /n). Only before displaying the content in your web page (but not in a textarea) you use nl2br.

Similar Threads

  1. Catalyst command line Installation problem
    By Bricklayer in forum Hardware Peripherals
    Replies: 4
    Last Post: 03-06-2010, 01:27 PM
  2. How to use TextArea class?
    By Protectors in forum Software Development
    Replies: 4
    Last Post: 06-03-2010, 04:49 PM
  3. what is textarea tag in html ?
    By Ramiroo in forum Software Development
    Replies: 3
    Last Post: 20-11-2009, 05:11 PM
  4. line wireless problem!
    By Swetlano in forum Networking & Security
    Replies: 4
    Last Post: 10-02-2009, 11:09 PM
  5. Line Height Problem
    By Dr.pter in forum Software Development
    Replies: 3
    Last Post: 27-08-2008, 01:03 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,718,181,678.90641 seconds with 16 queries