Jump to content

array data from MySQL to textarea help


chaz697

Recommended Posts

hey guys... im new here, but have read many posts you guys have made and it has helped me alot in the past,

 

basically i have been writing php for a short period and am doing quite well, but i need help on some things, and i signed up to get help from you.

 

the first thing i need to get help with is arraying data from a database onto a textarea, so it can be used like an 'edit' feature for news feeds etc...

i know how to get the information off the database into the text area using an array function, but because when i post new news, the line breaks go into the database as '\r\n' i need to know how to get it onto the text area and replace the \r\n with line breaks so it doesnt show up like  "<textarea name='news'>hello this is a new site\r\nWelcome</textarea>"

can you guys help me?

Link to comment
https://forums.phpfreaks.com/topic/94518-array-data-from-mysql-to-textarea-help/
Share on other sites

$textbox=nl2br($_PSOT['textbox'])

 

http://uk2.php.net/nl2br

 

or

 

$textbox=str_replace("\n\r",'<Br>',$_POST['textarea']);

 

 

However if you upload it as <Br> then you have to remove them when editing.

 

The best way to go is keep the \n\r in your data string and on your new page use "echo nl2br($row['textbox']);"

 

Regards

Liam

replacing the \r\n with <br> will show <br> in the textarea, i need it to show just a line break in a textarea.

 

i have no problem arraying the news on the page and showing a line break, but when i make an edit page, the textarea arrays the '\r\n' or '<br>'

 

http://www.sourcetournaments.co.uk/test.php

 

that is my page... how do i replace those '\r\n' with a line break in a text area

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.