Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 23-03-2009
Member
 
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>"
Reply With Quote
  #2  
Old 23-03-2009
Member
 
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.
Reply With Quote
  #3  
Old 23-03-2009
Member
 
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.
Reply With Quote
  #4  
Old 23-03-2009
Member
 
Join Date: Nov 2008
Posts: 996
Re: Problem with line in a textarea

What do you recommend?
Reply With Quote
  #5  
Old 23-03-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 07:20 AM.