kensmith Posted December 22, 2004 Share Posted December 22, 2004 I paste and copy articles in to a textarea. When I save it to a MYSQL table and then re-read the data, it is all strung together. If I physically type <br> after each carriage return, I get the expect results. How can I do this without having to type <br> manually? Thanks, Ken Quote Link to comment https://forums.phpfreaks.com/topic/2103-textarea-and-adding-carriage-returns/ Share on other sites More sharing options...
obsidian Posted December 22, 2004 Share Posted December 22, 2004 I paste and copy articles in to a textarea. When I save it to a MYSQL table and then re-read the data, it is all strung together. If I physically type <br> after each carriage return, I get the expect results. How can I do this without having to type <br> manually? Thanks, Ken 185485[/snapback] check out the nl2br() function. if you input the textarea value as nl2br($textareaValue), it will change all the newlines to <br /> for you! Quote Link to comment https://forums.phpfreaks.com/topic/2103-textarea-and-adding-carriage-returns/#findComment-6883 Share on other sites More sharing options...
kensmith Posted December 22, 2004 Author Share Posted December 22, 2004 check out the nl2br() function. if you input the textarea value as nl2br($textareaValue), it will change all the newlines to <br /> for you! 185491[/snapback] Thanks, that worked great. Now I have to go through my 200+ articles and remove the <br> from all of them! LOL Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/2103-textarea-and-adding-carriage-returns/#findComment-6884 Share on other sites More sharing options...
Pilot-Doofy Posted December 22, 2004 Share Posted December 22, 2004 Thanks, that worked great. Now I have to go through my 200+ articles and remove the <br> from all of them! LOL Thanks. 185496[/snapback] You can just do this: // replace <br> with <br /> even though i dont know why lol ## get all the stuff from the database $text = $array_retrieved_from_database['field']; // change this to fit $cur_id = $array_retrieved_from_database['field_id']; // change this to fit $text = str_replace("<br>", "<br />" $text); mysql_query("UPDATE table SET field = '$text' WHERE id = '$cur_id'"); Hope that helped. Quote Link to comment https://forums.phpfreaks.com/topic/2103-textarea-and-adding-carriage-returns/#findComment-6885 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.