Jump to content

Archived

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

kensmith

Textarea and adding carriage returns

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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.