Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/2103-textarea-and-adding-carriage-returns/
Share on other sites

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!

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.

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.

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.