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
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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.