Jump to content

Converting textarea text into pure html?


SC__Programmer

Recommended Posts

I'm trying to change the textarea's value into pure html.

 

So like if a textarea has this,

Test

Test

I want to change it to html all on one link like this,

Test<br><br>Test

 

How would i do that?ive looked at WYSIWYG editors but they're to much coding for what i want.

Link to comment
https://forums.phpfreaks.com/topic/251223-converting-textarea-text-into-pure-html/
Share on other sites

That isnt working,ill explain it better :)

 

I have some HTML in a mysql database like <div>Test<br>Test</div>,i want to be able to display that like this,

<div>Test
Test</div>

Then save it back in the database like this,

<div>Test<br>Test</div>

How?

 

Im trying to make a homepage welcome thingy,in the admin panel you have a textarea box where you edit the text.when i load the value of the database(Test<br><br>Test) it shows up in the textarea as Test<br><br>Test,i want it to show up as

Test

Test

and when the user gets done editing its going to be like this

Edited

Edited

and when they push save i want it to convert to Edited<br><br>Edited so i can save it to the database.

  • 2 weeks later...

Save the data as-is to the database. Before printing it to the screen, run the text through the php nl2br() function. When you are putting the data into a textarea, you won't have to do anything, as you save it in its original form in the database, so putting it back in a textarea will make it exactly the same as it was before it was saved.

Archived

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

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