chaz697 Posted March 5, 2008 Share Posted March 5, 2008 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? Quote Link to comment Share on other sites More sharing options...
shocker-z Posted March 5, 2008 Share Posted March 5, 2008 $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 Quote Link to comment Share on other sites More sharing options...
chaz697 Posted March 5, 2008 Author Share Posted March 5, 2008 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 Quote Link to comment Share on other sites More sharing options...
discomatt Posted March 5, 2008 Share Posted March 5, 2008 str_replace('\r\n', "\r\n", $subject); Single quotes are not parsed, and taken literally, while double quotes are parsed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.